Struct der::Any[][src]

pub struct Any<'a> { /* fields omitted */ }
Expand description

ASN.1 ANY: represents any explicitly tagged ASN.1 value.

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

impl<'a> Any<'a>[src]

pub fn new(tag: Tag, value: &'a [u8]) -> Result<Self>[src]

Create a new Any from the provided Tag and slice.

pub fn tag(self) -> Tag[src]

Get the tag for this Any type.

pub fn len(self) -> Length[src]

Get the Length of this Any type’s value.

pub fn is_empty(self) -> bool[src]

Is the body of this Any type empty?

pub fn is_null(self) -> bool[src]

Is this value an ASN.1 NULL value?

pub fn as_bytes(self) -> &'a [u8][src]

Get the raw value for this Any type as a byte slice.

pub fn bit_string(self) -> Result<BitString<'a>>[src]

Attempt to decode an ASN.1 BIT STRING.

pub fn generalized_time(self) -> Result<GeneralizedTime>[src]

Attempt to decode an ASN.1 GeneralizedTime.

pub fn ia5_string(self) -> Result<Ia5String<'a>>[src]

Attempt to decode an ASN.1 IA5String.

pub fn octet_string(self) -> Result<OctetString<'a>>[src]

Attempt to decode an ASN.1 OCTET STRING.

pub fn oid(self) -> Result<ObjectIdentifier>[src]

This is supported on crate feature oid only.

Attempt to decode an ASN.1 OBJECT IDENTIFIER.

pub fn printable_string(self) -> Result<PrintableString<'a>>[src]

Attempt to decode an ASN.1 PrintableString.

pub fn sequence<F, T>(self, f: F) -> Result<T> where
    F: FnOnce(&mut Decoder<'a>) -> Result<T>, 
[src]

Attempt to decode this value an ASN.1 SEQUENCE, creating a new nested Decoder and calling the provided argument with it.

pub fn utc_time(self) -> Result<UtcTime>[src]

Attempt to decode an ASN.1 UTCTime.

pub fn utf8_string(self) -> Result<Utf8String<'a>>[src]

Attempt to decode an ASN.1 UTF8String.

Trait Implementations

impl<'a> Choice<'a> for Any<'a>[src]

fn can_decode(_: Tag) -> bool[src]

Is the provided Tag decodable as a variant of this CHOICE?

impl<'a> Clone for Any<'a>[src]

fn clone(&self) -> Any<'a>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a> Debug for Any<'a>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'a> Decodable<'a> for Any<'a>[src]

fn decode(decoder: &mut Decoder<'a>) -> Result<Any<'a>>[src]

Attempt to decode this message using the provided decoder.

fn from_der(bytes: &'a [u8]) -> Result<Self>[src]

Parse Self from the provided DER-encoded byte slice.

impl<'a> Encodable for Any<'a>[src]

fn encoded_len(&self) -> Result<Length>[src]

Compute the length of this value in bytes when encoded as ASN.1 DER.

fn encode(&self, encoder: &mut Encoder<'_>) -> Result<()>[src]

Encode this value as ASN.1 DER using the provided Encoder.

fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>[src]

Encode this value to the provided byte slice, returning a sub-slice containing the encoded message. Read more

fn encode_to_vec(&self, buf: &mut Vec<u8>) -> Result<Length>[src]

This is supported on crate feature alloc only.

Encode this message as ASN.1 DER, appending it to the provided byte vector. Read more

fn to_vec(&self) -> Result<Vec<u8>>[src]

This is supported on crate feature alloc only.

Serialize this message as a byte vector.

impl<'a> From<&'a ObjectIdentifier> for Any<'a>[src]

fn from(oid: &'a ObjectIdentifier) -> Any<'a>[src]

Performs the conversion.

impl<'a> From<()> for Any<'a>[src]

fn from(_: ()) -> Any<'a>[src]

Performs the conversion.

impl<'a> From<BitString<'a>> for Any<'a>[src]

fn from(bit_string: BitString<'a>) -> Any<'a>[src]

Performs the conversion.

impl<'a> From<Ia5String<'a>> for Any<'a>[src]

fn from(printable_string: Ia5String<'a>) -> Any<'a>[src]

Performs the conversion.

impl<'a> From<Null> for Any<'a>[src]

fn from(_: Null) -> Any<'a>[src]

Performs the conversion.

impl<'a> From<OctetString<'a>> for Any<'a>[src]

fn from(octet_string: OctetString<'a>) -> Any<'a>[src]

Performs the conversion.

impl<'a> From<PrintableString<'a>> for Any<'a>[src]

fn from(printable_string: PrintableString<'a>) -> Any<'a>[src]

Performs the conversion.

impl<'a> From<Sequence<'a>> for Any<'a>[src]

fn from(seq: Sequence<'a>) -> Any<'a>[src]

Performs the conversion.

impl<'a, T> From<SetOfRef<'a, T>> for Any<'a> where
    T: Clone + Decodable<'a> + Encodable + Ord
[src]

fn from(set: SetOfRef<'a, T>) -> Any<'a>[src]

Performs the conversion.

impl<'a> From<Utf8String<'a>> for Any<'a>[src]

fn from(utf8_string: Utf8String<'a>) -> Any<'a>[src]

Performs the conversion.

impl<'a> Ord for Any<'a>[src]

fn cmp(&self, other: &Any<'a>) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl<'a> PartialEq<Any<'a>> for Any<'a>[src]

fn eq(&self, other: &Any<'a>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Any<'a>) -> bool[src]

This method tests for !=.

impl<'a> PartialOrd<Any<'a>> for Any<'a>[src]

fn partial_cmp(&self, other: &Any<'a>) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<'a> TryFrom<&'a [u8]> for Any<'a>[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(bytes: &'a [u8]) -> Result<Any<'a>>[src]

Performs the conversion.

impl TryFrom<Any<'_>> for GeneralizedTime[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'_>) -> Result<GeneralizedTime>[src]

Performs the conversion.

impl TryFrom<Any<'_>> for Null[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'_>) -> Result<Null>[src]

Performs the conversion.

impl TryFrom<Any<'_>> for ObjectIdentifier[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'_>) -> Result<ObjectIdentifier>[src]

Performs the conversion.

impl TryFrom<Any<'_>> for UtcTime[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'_>) -> Result<UtcTime>[src]

Performs the conversion.

impl<'a, N> TryFrom<Any<'a>> for BigUInt<'a, N> where
    N: Unsigned + NonZero
[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'a>) -> Result<BigUInt<'a, N>>[src]

Performs the conversion.

impl<'a> TryFrom<Any<'a>> for BitString<'a>[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'a>) -> Result<BitString<'a>>[src]

Performs the conversion.

impl<'a> TryFrom<Any<'a>> for Ia5String<'a>[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'a>) -> Result<Ia5String<'a>>[src]

Performs the conversion.

impl<'a> TryFrom<Any<'a>> for OctetString<'a>[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'a>) -> Result<OctetString<'a>>[src]

Performs the conversion.

impl<'a> TryFrom<Any<'a>> for PrintableString<'a>[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'a>) -> Result<PrintableString<'a>>[src]

Performs the conversion.

impl<'a> TryFrom<Any<'a>> for Sequence<'a>[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'a>) -> Result<Self>[src]

Performs the conversion.

impl<'a, T> TryFrom<Any<'a>> for SetOfRef<'a, T> where
    T: Clone + Decodable<'a> + Encodable + Ord
[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'a>) -> Result<Self>[src]

Performs the conversion.

impl<'a> TryFrom<Any<'a>> for Utf8String<'a>[src]

type Error = Error

The type returned in the event of a conversion error.

fn try_from(any: Any<'a>) -> Result<Utf8String<'a>>[src]

Performs the conversion.

impl<'a> Copy for Any<'a>[src]

impl<'a> Eq for Any<'a>[src]

impl<'a> StructuralEq for Any<'a>[src]

impl<'a> StructuralPartialEq for Any<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Any<'a>

impl<'a> Send for Any<'a>

impl<'a> Sync for Any<'a>

impl<'a> Unpin for Any<'a>

impl<'a> UnwindSafe for Any<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.