Open dzil123 opened 1 month ago
OctetString(Ref)
to Vec<u8>
Thank you, that PR fixes the first error "trait bound is not satisfied" on the call of ::der::asn1::OctetStringRef::decode(reader)?.try_into()?
in the macro expansion.
However, there is still the second error "mismatched types", occurring on the call of ::der::asn1::OctetStringRef::new(self.bar)?.encode(writer)?
.
I'm trying to use the
der
andder_derive
crates to implement encoding and encoding a struct containing aVec<u8>
as anOCTET STRING
. I need my struct to be owned, not borrowed from the input DER bytes.Using
OctetString
in the struct definition is inconvenient because I must use the falliblenew()
method when manually creating an instance of the struct. I would rather the struct useVec<u8>
directly, and keep the der-specific types and encoding error in the encode and decode steps.I thought
#[asn1(type = "OCTET STRING")]
would implement this, as the documentation states:This does not work. Contrary to the documentation, the macro performs an intermediate conversion to
OctetStringRef
, which does not have aTryFrom
andInto
implemented forVec<u8>
.