pub struct AnyRef<'a> { /* private fields */ }Expand description
ASN.1 ANY: represents any explicitly tagged ASN.1 value.
This is a zero-copy reference type which borrows from the input data.
Technically ANY hasn’t been a recommended part of ASN.1 since the X.209
revision from 1988. It was deprecated and replaced by Information Object
Classes in X.680 in 1994, and X.690 no longer refers to it whatsoever.
Nevertheless, this crate defines an ANY type as it remains a familiar
and useful concept which is still extensively used in things like
PKI-related RFCs.
Implementations§
Source§impl<'a> AnyRef<'a>
impl<'a> AnyRef<'a>
Sourcepub const fn new(tag: Tag, bytes: &'a [u8]) -> Result<Self, Error>
pub const fn new(tag: Tag, bytes: &'a [u8]) -> Result<Self, Error>
Create a new AnyRef from the provided Tag and DER bytes.
§Errors
Returns Error with ErrorKind::Length if bytes is too long.
Sourcepub fn decode_as<T>(self) -> Result<T, <T as DecodeValue<'a>>::Error>where
T: Choice<'a> + DecodeValue<'a>,
pub fn decode_as<T>(self) -> Result<T, <T as DecodeValue<'a>>::Error>where
T: Choice<'a> + DecodeValue<'a>,
Sourcepub fn decode_as_encoding<T>(
self,
encoding: EncodingRules,
) -> Result<T, <T as DecodeValue<'a>>::Error>where
T: Choice<'a> + DecodeValue<'a>,
pub fn decode_as_encoding<T>(
self,
encoding: EncodingRules,
) -> Result<T, <T as DecodeValue<'a>>::Error>where
T: Choice<'a> + DecodeValue<'a>,
Trait Implementations§
Source§impl<'a, 'arbitrary: 'a> Arbitrary<'arbitrary> for AnyRef<'a>
impl<'a, 'arbitrary: 'a> Arbitrary<'arbitrary> for AnyRef<'a>
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§impl<'a> Decode<'a> for AnyRef<'a>
impl<'a> Decode<'a> for AnyRef<'a>
Source§fn decode<R: Reader<'a>>(reader: &mut R) -> Result<AnyRef<'a>, Error>
fn decode<R: Reader<'a>>(reader: &mut R) -> Result<AnyRef<'a>, Error>
Attempt to decode this TLV message using the provided decoder. Read more
Source§fn from_ber(bytes: &'a [u8]) -> Result<Self, Self::Error>
fn from_ber(bytes: &'a [u8]) -> Result<Self, Self::Error>
Available on crate feature
ber only.Parse
Self from the provided BER-encoded byte slice. Read moreSource§impl<'a> DecodeValue<'a> for AnyRef<'a>
impl<'a> DecodeValue<'a> for AnyRef<'a>
Source§impl EncodeValue for AnyRef<'_>
impl EncodeValue for AnyRef<'_>
Source§impl<'a, const MAX_SIZE: usize> From<&'a ObjectIdentifier<MAX_SIZE>> for AnyRef<'a>
Available on crate feature oid only.
impl<'a, const MAX_SIZE: usize> From<&'a ObjectIdentifier<MAX_SIZE>> for AnyRef<'a>
Available on crate feature
oid only.Source§fn from(oid: &'a ObjectIdentifier<MAX_SIZE>) -> AnyRef<'a>
fn from(oid: &'a ObjectIdentifier<MAX_SIZE>) -> AnyRef<'a>
Converts to this type from the input type.
Source§impl<'a> From<&'a OctetStringRef> for AnyRef<'a>
impl<'a> From<&'a OctetStringRef> for AnyRef<'a>
Source§fn from(octet_string: &'a OctetStringRef) -> AnyRef<'a>
fn from(octet_string: &'a OctetStringRef) -> AnyRef<'a>
Converts to this type from the input type.
Source§impl<'a> From<&'a PrintableString> for AnyRef<'a>
Available on crate feature alloc only.
impl<'a> From<&'a PrintableString> for AnyRef<'a>
Available on crate feature
alloc only.Source§fn from(printable_string: &'a PrintableString) -> AnyRef<'a>
fn from(printable_string: &'a PrintableString) -> AnyRef<'a>
Converts to this type from the input type.
Source§impl<'a> From<&'a TeletexString> for AnyRef<'a>
Available on crate feature alloc only.
impl<'a> From<&'a TeletexString> for AnyRef<'a>
Available on crate feature
alloc only.Source§fn from(teletex_string: &'a TeletexString) -> AnyRef<'a>
fn from(teletex_string: &'a TeletexString) -> AnyRef<'a>
Converts to this type from the input type.
Source§impl<'a> From<Ia5StringRef<'a>> for AnyRef<'a>
impl<'a> From<Ia5StringRef<'a>> for AnyRef<'a>
Source§fn from(internationalized_string: Ia5StringRef<'a>) -> AnyRef<'a>
fn from(internationalized_string: Ia5StringRef<'a>) -> AnyRef<'a>
Converts to this type from the input type.
Source§impl<'a> From<PrintableStringRef<'a>> for AnyRef<'a>
impl<'a> From<PrintableStringRef<'a>> for AnyRef<'a>
Source§fn from(printable_string: PrintableStringRef<'a>) -> AnyRef<'a>
fn from(printable_string: PrintableStringRef<'a>) -> AnyRef<'a>
Converts to this type from the input type.
Source§impl<'a> From<TeletexStringRef<'a>> for AnyRef<'a>
impl<'a> From<TeletexStringRef<'a>> for AnyRef<'a>
Source§fn from(teletex_string: TeletexStringRef<'a>) -> AnyRef<'a>
fn from(teletex_string: TeletexStringRef<'a>) -> AnyRef<'a>
Converts to this type from the input type.
Source§impl<'a> From<Utf8StringRef<'a>> for AnyRef<'a>
impl<'a> From<Utf8StringRef<'a>> for AnyRef<'a>
Source§fn from(utf_string: Utf8StringRef<'a>) -> AnyRef<'a>
fn from(utf_string: Utf8StringRef<'a>) -> AnyRef<'a>
Converts to this type from the input type.
Source§impl<'a> From<VideotexStringRef<'a>> for AnyRef<'a>
impl<'a> From<VideotexStringRef<'a>> for AnyRef<'a>
Source§fn from(videotex_string: VideotexStringRef<'a>) -> AnyRef<'a>
fn from(videotex_string: VideotexStringRef<'a>) -> AnyRef<'a>
Converts to this type from the input type.
Source§impl<'a> Ord for AnyRef<'a>
impl<'a> Ord for AnyRef<'a>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialOrd for AnyRef<'a>
impl<'a> PartialOrd for AnyRef<'a>
Source§impl<'a> RefToOwned<'a> for AnyRef<'a>
Available on crate feature alloc only.
impl<'a> RefToOwned<'a> for AnyRef<'a>
Available on crate feature
alloc only.Source§impl<const MAX_SIZE: usize> TryFrom<AnyRef<'_>> for ObjectIdentifier<MAX_SIZE>
Available on crate feature oid only.
impl<const MAX_SIZE: usize> TryFrom<AnyRef<'_>> for ObjectIdentifier<MAX_SIZE>
Available on crate feature
oid only.Source§impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for &'a OctetStringRef
impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for &'a OctetStringRef
Source§impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for BitStringRef<'a>
impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for BitStringRef<'a>
Source§impl<'__der> TryFrom<AnyRef<'__der>> for GeneralizedTime
impl<'__der> TryFrom<AnyRef<'__der>> for GeneralizedTime
Source§impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for Ia5StringRef<'a>
impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for Ia5StringRef<'a>
Source§impl<'__der> TryFrom<AnyRef<'__der>> for OctetString
Available on crate feature alloc only.
impl<'__der> TryFrom<AnyRef<'__der>> for OctetString
Available on crate feature
alloc only.Source§impl<'__der> TryFrom<AnyRef<'__der>> for PrintableString
Available on crate feature alloc only.
impl<'__der> TryFrom<AnyRef<'__der>> for PrintableString
Available on crate feature
alloc only.Source§impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for PrintableStringRef<'a>
impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for PrintableStringRef<'a>
Source§impl<'__der> TryFrom<AnyRef<'__der>> for TeletexString
Available on crate feature alloc only.
impl<'__der> TryFrom<AnyRef<'__der>> for TeletexString
Available on crate feature
alloc only.Source§impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for TeletexStringRef<'a>
impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for TeletexStringRef<'a>
Source§impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for Utf8StringRef<'a>
impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for Utf8StringRef<'a>
Source§impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for VideotexStringRef<'a>
impl<'__der: 'a, 'a> TryFrom<AnyRef<'__der>> for VideotexStringRef<'a>
Source§impl<'a> TryFrom<AnyRef<'a>> for SystemTime
Available on crate feature std only.
impl<'a> TryFrom<AnyRef<'a>> for SystemTime
Available on crate feature
std only.impl<'a> Copy for AnyRef<'a>
impl<'a> Eq for AnyRef<'a>
impl<'a> StructuralPartialEq for AnyRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for AnyRef<'a>
impl<'a> RefUnwindSafe for AnyRef<'a>
impl<'a> Send for AnyRef<'a>
impl<'a> Sync for AnyRef<'a>
impl<'a> Unpin for AnyRef<'a>
impl<'a> UnwindSafe for AnyRef<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Encode for T
impl<T> Encode for T
Source§fn encoded_len(&self) -> Result<Length, Error>
fn encoded_len(&self) -> Result<Length, Error>
Compute the length of this TLV object in bytes when encoded as ASN.1 DER. Read more
Source§fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>
Encode this TLV object to the provided byte slice, returning a sub-slice
containing the encoded message. Read more