Trait Decoder

Source
pub trait Decoder: Sized {
    type Error: Error + Into<DecodeError> + From<DecodeError>;

Show 38 methods // Required methods fn codec(&self) -> Codec; fn decode_any(&mut self) -> Result<Any, Self::Error>; fn decode_bit_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<BitString, Self::Error>; fn decode_bool(&mut self, tag: Tag) -> Result<bool, Self::Error>; fn decode_enumerated<E: Enumerated>( &mut self, tag: Tag, ) -> Result<E, Self::Error>; fn decode_integer<I: IntegerType>( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<I, Self::Error>; fn decode_null(&mut self, tag: Tag) -> Result<(), Self::Error>; fn decode_object_identifier( &mut self, tag: Tag, ) -> Result<ObjectIdentifier, Self::Error>; fn decode_sequence<D, DF, F>( &mut self, tag: Tag, default_initializer_fn: Option<DF>, decode_fn: F, ) -> Result<D, Self::Error> where D: Constructed, DF: FnOnce() -> D, F: FnOnce(&mut Self) -> Result<D, Self::Error>; fn decode_sequence_of<D: Decode>( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<Vec<D>, Self::Error>; fn decode_set_of<D: Decode + Ord>( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<SetOf<D>, Self::Error>; fn decode_octet_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<Vec<u8>, Self::Error>; fn decode_utf8_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<Utf8String, Self::Error>; fn decode_visible_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<VisibleString, Self::Error>; fn decode_general_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<GeneralString, Self::Error>; fn decode_ia5_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<Ia5String, Self::Error>; fn decode_printable_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<PrintableString, Self::Error>; fn decode_numeric_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<NumericString, Self::Error>; fn decode_teletex_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<TeletexString, Self::Error>; fn decode_bmp_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<BmpString, Self::Error>; fn decode_explicit_prefix<D: Decode>( &mut self, tag: Tag, ) -> Result<D, Self::Error>; fn decode_utc_time(&mut self, tag: Tag) -> Result<UtcTime, Self::Error>; fn decode_generalized_time( &mut self, tag: Tag, ) -> Result<GeneralizedTime, Self::Error>; fn decode_set<FIELDS, SET, D, F>( &mut self, tag: Tag, decode_fn: D, field_fn: F, ) -> Result<SET, Self::Error> where SET: Decode + Constructed, FIELDS: Decode, D: Fn(&mut Self, usize, Tag) -> Result<FIELDS, Self::Error>, F: FnOnce(Vec<FIELDS>) -> Result<SET, Self::Error>; fn decode_choice<D>( &mut self, constraints: Constraints<'_>, ) -> Result<D, Self::Error> where D: DecodeChoice; fn decode_optional<D: Decode>(&mut self) -> Result<Option<D>, Self::Error>; fn decode_optional_with_tag<D: Decode>( &mut self, tag: Tag, ) -> Result<Option<D>, Self::Error>; fn decode_optional_with_constraints<D: Decode>( &mut self, constraints: Constraints<'_>, ) -> Result<Option<D>, Self::Error>; fn decode_optional_with_tag_and_constraints<D: Decode>( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<Option<D>, Self::Error>; fn decode_extension_addition_with_constraints<D>( &mut self, constraints: Constraints<'_>, ) -> Result<Option<D>, Self::Error> where D: Decode; fn decode_extension_addition_group<D: Decode + Constructed>( &mut self, ) -> Result<Option<D>, Self::Error>; // Provided methods fn decode_default<D: Decode, F: FnOnce() -> D>( &mut self, default_fn: F, ) -> Result<D, Self::Error> { ... } fn decode_default_with_tag<D: Decode, F: FnOnce() -> D>( &mut self, tag: Tag, default_fn: F, ) -> Result<D, Self::Error> { ... } fn decode_default_with_constraints<D: Decode, F: FnOnce() -> D>( &mut self, default_fn: F, constraints: Constraints<'_>, ) -> Result<D, Self::Error> { ... } fn decode_default_with_tag_and_constraints<D: Decode, F: FnOnce() -> D>( &mut self, tag: Tag, default_fn: F, constraints: Constraints<'_>, ) -> Result<D, Self::Error> { ... } fn decode_extension_addition<D>(&mut self) -> Result<Option<D>, Self::Error> where D: Decode { ... } fn decode_extension_addition_with_default<D: Decode, F: FnOnce() -> D>( &mut self, default_fn: F, ) -> Result<D, Self::Error> { ... } fn decode_extension_addition_with_default_and_constraints<D: Decode, F: FnOnce() -> D>( &mut self, default_fn: F, constraints: Constraints<'_>, ) -> Result<D, Self::Error> { ... }
}
Expand description

A data format decode any ASN.1 data type.

Required Associated Types§

Required Methods§

Source

fn codec(&self) -> Codec

Returns codec variant of Codec that current decoder is decoding.

Source

fn decode_any(&mut self) -> Result<Any, Self::Error>

Decode a unknown ASN.1 value identified by tag from the available input.

Source

fn decode_bit_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<BitString, Self::Error>

Decode a BIT STRING identified by tag from the available input.

Source

fn decode_bool(&mut self, tag: Tag) -> Result<bool, Self::Error>

Decode a BOOL identified by tag from the available input.

Source

fn decode_enumerated<E: Enumerated>( &mut self, tag: Tag, ) -> Result<E, Self::Error>

Decode an enumerated enum’s discriminant identified by tag from the available input.

Source

fn decode_integer<I: IntegerType>( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<I, Self::Error>

Decode a INTEGER identified by tag from the available input.

Source

fn decode_null(&mut self, tag: Tag) -> Result<(), Self::Error>

Decode NULL identified by tag from the available input.

Source

fn decode_object_identifier( &mut self, tag: Tag, ) -> Result<ObjectIdentifier, Self::Error>

Decode a OBJECT IDENTIFIER identified by tag from the available input.

Source

fn decode_sequence<D, DF, F>( &mut self, tag: Tag, default_initializer_fn: Option<DF>, decode_fn: F, ) -> Result<D, Self::Error>
where D: Constructed, DF: FnOnce() -> D, F: FnOnce(&mut Self) -> Result<D, Self::Error>,

Decode a SEQUENCE identified by tag from the available input. Returning a new Decoder containing the sequence’s contents to be decoded.

Source

fn decode_sequence_of<D: Decode>( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<Vec<D>, Self::Error>

Decode a SEQUENCE OF D where D: Decode identified by tag from the available input.

Source

fn decode_set_of<D: Decode + Ord>( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<SetOf<D>, Self::Error>

Decode a SET OF D where D: Decode identified by tag from the available input.

Source

fn decode_octet_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<Vec<u8>, Self::Error>

Decode a OCTET STRING identified by tag from the available input.

Source

fn decode_utf8_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<Utf8String, Self::Error>

Decode a UTF8 STRING identified by tag from the available input.

Source

fn decode_visible_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<VisibleString, Self::Error>

Decode a VisibleString identified by tag from the available input.

Source

fn decode_general_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<GeneralString, Self::Error>

Decode a Ia5String identified by tag from the available input.

Source

fn decode_ia5_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<Ia5String, Self::Error>

Decode a Ia5String identified by tag from the available input.

Source

fn decode_printable_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<PrintableString, Self::Error>

Decode a PrintableString identified by tag from the available input.

Source

fn decode_numeric_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<NumericString, Self::Error>

Decode a NumericString identified by tag from the available input.

Source

fn decode_teletex_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<TeletexString, Self::Error>

Decode a TeletexString identified by tag from the available input.

Source

fn decode_bmp_string( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<BmpString, Self::Error>

Decode a BmpString identified by tag from the available input.

Source

fn decode_explicit_prefix<D: Decode>( &mut self, tag: Tag, ) -> Result<D, Self::Error>

Decode an ASN.1 value that has been explicitly prefixed with tag from the available input.

Source

fn decode_utc_time(&mut self, tag: Tag) -> Result<UtcTime, Self::Error>

Decode a UtcTime identified by tag from the available input.

Source

fn decode_generalized_time( &mut self, tag: Tag, ) -> Result<GeneralizedTime, Self::Error>

Decode a GeneralizedTime identified by tag from the available input.

Source

fn decode_set<FIELDS, SET, D, F>( &mut self, tag: Tag, decode_fn: D, field_fn: F, ) -> Result<SET, Self::Error>
where SET: Decode + Constructed, FIELDS: Decode, D: Fn(&mut Self, usize, Tag) -> Result<FIELDS, Self::Error>, F: FnOnce(Vec<FIELDS>) -> Result<SET, Self::Error>,

Decode a SET identified by tag from the available input. Decoding SETs works a little different than other methods, as you need to provide two types SET and FIELDS, SET represents the complete type, and FIELDS must represent a CHOICE with a variant for each field from SET. As with SETs the field order is not guarenteed, so you’ll have map from Vec<FIELDS> to SET in decode_operation.

Source

fn decode_choice<D>( &mut self, constraints: Constraints<'_>, ) -> Result<D, Self::Error>
where D: DecodeChoice,

Decode an the optional value in a SEQUENCE or SET.

Source

fn decode_optional<D: Decode>(&mut self) -> Result<Option<D>, Self::Error>

Decode an the optional value in a SEQUENCE or SET.

Source

fn decode_optional_with_tag<D: Decode>( &mut self, tag: Tag, ) -> Result<Option<D>, Self::Error>

Decode an the optional value in a SEQUENCE or SET with tag. Passing the correct tag is required even when used with codecs where the tag is not present.

Source

fn decode_optional_with_constraints<D: Decode>( &mut self, constraints: Constraints<'_>, ) -> Result<Option<D>, Self::Error>

Decode an the optional value in a SEQUENCE or SET with constraints.

Source

fn decode_optional_with_tag_and_constraints<D: Decode>( &mut self, tag: Tag, constraints: Constraints<'_>, ) -> Result<Option<D>, Self::Error>

Decode an the optional value in a SEQUENCE or SET with tag and constraints.

Source

fn decode_extension_addition_with_constraints<D>( &mut self, constraints: Constraints<'_>, ) -> Result<Option<D>, Self::Error>
where D: Decode,

Decode an extension addition with constraints in a SEQUENCE or SET

Source

fn decode_extension_addition_group<D: Decode + Constructed>( &mut self, ) -> Result<Option<D>, Self::Error>

Provided Methods§

Source

fn decode_default<D: Decode, F: FnOnce() -> D>( &mut self, default_fn: F, ) -> Result<D, Self::Error>

Decode a DEFAULT value in a SEQUENCE or SET.

Source

fn decode_default_with_tag<D: Decode, F: FnOnce() -> D>( &mut self, tag: Tag, default_fn: F, ) -> Result<D, Self::Error>

Decode a DEFAULT value in a SEQUENCE or SET with tag and default_fn.

Source

fn decode_default_with_constraints<D: Decode, F: FnOnce() -> D>( &mut self, default_fn: F, constraints: Constraints<'_>, ) -> Result<D, Self::Error>

Decode a DEFAULT value with constraints in a SEQUENCE or SET with a given default_fn.

Source

fn decode_default_with_tag_and_constraints<D: Decode, F: FnOnce() -> D>( &mut self, tag: Tag, default_fn: F, constraints: Constraints<'_>, ) -> Result<D, Self::Error>

Decode a DEFAULT value in a SEQUENCE or SET with tag, constraints and default_fn.

Source

fn decode_extension_addition<D>(&mut self) -> Result<Option<D>, Self::Error>
where D: Decode,

Source

fn decode_extension_addition_with_default<D: Decode, F: FnOnce() -> D>( &mut self, default_fn: F, ) -> Result<D, Self::Error>

Decode a DEFAULT value in a SEQUENCE’s or SET’s extension

Source

fn decode_extension_addition_with_default_and_constraints<D: Decode, F: FnOnce() -> D>( &mut self, default_fn: F, constraints: Constraints<'_>, ) -> Result<D, Self::Error>

Decode a DEFAULT value with constraints in a SEQUENCE’s or SET’s extension

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Decoder for rasn::jer::de::Decoder

Source§

impl<'input> Decoder for rasn::aper::Decoder<'input>

Source§

impl<'input> Decoder for rasn::ber::de::Decoder<'input>

Source§

impl<'input> Decoder for rasn::oer::de::Decoder<'input>