formats icon indicating copy to clipboard operation
formats copied to clipboard

der: why don't more ASN.1 types support conversion to `Any(Ref)`?

Open RickyDaMa opened this issue 6 months ago • 11 comments

Hi there! I'm new to the RustCrypto libraries, so if I'm holding them wrong and there's a smooth way to go from one to the other, please point it out 😅

I'm trying to build an x509_cert::attr::Attribute by hand using constants. What I'd like to do is something like this:

let attr = Attribute {
    oid: SPC_LINK,
    values: SetOfVec::from_iter(
        [BitString::from_bytes(&[0x00]).unwrap().into()] // .into() here converts BitString to Any
    ).unwrap(),
};

Is there a reason why we don't have implementations such as From<BitStringRef<'a>> for AnyRef<'a>? If it's just a case of "no one has needed it yet", would you accept a PR for such things?

And on a similar note, could the derive macros also potentially implement Any conversion also? I guess you might struggle to distinguish between owned and borrowed structs to know which to implement (or how)

RickyDaMa avatar Aug 05 '25 15:08 RickyDaMa