Trait Decoder

Source
pub trait Decoder<const RCL: usize = 0, const ECL: usize = 0>: Sized {
    type Ok;
    type Error: Error + Into<DecodeError> + From<DecodeError>;
    type AnyDecoder<const R: usize, const E: usize>: Decoder<RCL, ECL, Ok = Self::Ok, Error = Self::Error> + Decoder;

Show 47 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_real<R: RealType>( &mut self, tag: Tag, constraints: Constraints, ) -> Result<R, 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<const RC: usize, const EC: usize, D, DF, F>( &mut self, tag: Tag, default_initializer_fn: Option<DF>, decode_fn: F, ) -> Result<D, Self::Error> where D: Constructed<RC, EC>, DF: FnOnce() -> D, F: FnOnce(&mut Self::AnyDecoder<RC, EC>) -> 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 + Eq + Hash>( &mut self, tag: Tag, constraints: Constraints, ) -> Result<SetOf<D>, Self::Error>; fn decode_octet_string<'buf, T>( &'buf mut self, tag: Tag, constraints: Constraints, ) -> Result<T, Self::Error> where T: From<&'buf [u8]> + From<Vec<u8>>; 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_graphic_string( &mut self, tag: Tag, constraints: Constraints, ) -> Result<GraphicString, 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_optional_with_explicit_prefix<D: Decode>( &mut self, tag: Tag, ) -> Result<Option<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_date(&mut self, tag: Tag) -> Result<Date, Self::Error>; fn decode_set<const RC: usize, const EC: usize, FIELDS, SET, D, F>( &mut self, tag: Tag, decode_fn: D, field_fn: F, ) -> Result<SET, Self::Error> where SET: Decode + Constructed<RC, EC>, FIELDS: Decode, D: Fn(&mut Self::AnyDecoder<RC, EC>, 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_explicit_tag_and_constraints<D>( &mut self, tag: Tag, constraints: Constraints, ) -> Result<Option<D>, Self::Error> where D: Decode; fn decode_extension_addition_with_tag_and_constraints<D>( &mut self, tag: Tag, constraints: Constraints, ) -> Result<Option<D>, Self::Error> where D: Decode; fn decode_extension_addition_group<const RC: usize, const EC: usize, D: Decode + Constructed<RC, EC>>( &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_tag<D>( &mut self, tag: Tag, ) -> Result<Option<D>, Self::Error> where D: Decode { ... } fn decode_extension_addition_with_constraints<D>( &mut self, constraints: Constraints, ) -> 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_tag<D: Decode, F: FnOnce() -> D>( &mut self, tag: Tag, 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> { ... } fn decode_extension_addition_with_default_and_tag_and_constraints<D: Decode, F: FnOnce() -> D>( &mut self, tag: Tag, default_fn: F, constraints: Constraints, ) -> Result<D, Self::Error> { ... }
}
Expand description

A data format decode any ASN.1 data type.

Const RCL is the count of root components in the root component list of a sequence or set. Const ECL is the count of extension additions in the extension addition component type list in a sequence or set.

Required Associated Types§

Source

type Ok

The associated success type returned on success.

Source

type Error: Error + Into<DecodeError> + From<DecodeError>

The associated error type returned on failure.

Source

type AnyDecoder<const R: usize, const E: usize>: Decoder<RCL, ECL, Ok = Self::Ok, Error = Self::Error> + Decoder

Helper type for decoding nested instances of Decoder with different fields.

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 an 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_real<R: RealType>( &mut self, tag: Tag, constraints: Constraints, ) -> Result<R, Self::Error>

Decode a REAL 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<const RC: usize, const EC: usize, D, DF, F>( &mut self, tag: Tag, default_initializer_fn: Option<DF>, decode_fn: F, ) -> Result<D, Self::Error>
where D: Constructed<RC, EC>, DF: FnOnce() -> D, F: FnOnce(&mut Self::AnyDecoder<RC, EC>) -> 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.

Const RC is the count of root components in a sequence. Const EC is the count of extension addition components in a sequence. Generic D is the sequence type. Generic DF is the closure that will initialize the sequence with default values, typically when no values are present. Generic F is the closure that will decode the sequence by decoding the fields in the order as defined in the type. NOTE: If you implement this manually, make sure to decode fields in the same order and pass the correct count of fields.

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 + Eq + Hash>( &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<'buf, T>( &'buf mut self, tag: Tag, constraints: Constraints, ) -> Result<T, Self::Error>
where T: From<&'buf [u8]> + From<Vec<u8>>,

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 GeneralString identified by tag from the available input.

Source

fn decode_graphic_string( &mut self, tag: Tag, constraints: Constraints, ) -> Result<GraphicString, Self::Error>

Decode a GraphicString 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_optional_with_explicit_prefix<D: Decode>( &mut self, tag: Tag, ) -> Result<Option<D>, Self::Error>

Decode an optional ASN.1 type 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_date(&mut self, tag: Tag) -> Result<Date, Self::Error>

Decode a ‘DATE’ identified by ‘tag’ from the available input

Source

fn decode_set<const RC: usize, const EC: usize, FIELDS, SET, D, F>( &mut self, tag: Tag, decode_fn: D, field_fn: F, ) -> Result<SET, Self::Error>
where SET: Decode + Constructed<RC, EC>, FIELDS: Decode, D: Fn(&mut Self::AnyDecoder<RC, EC>, 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.

Const RC is the count of root components in a sequence. Const EC is the count of extension addition components in a sequence. Generic FIELDS is the choice type, used by F to map the decoded field values correctly. Generic SET is the set type. Generic D is the closure that will decode the set by decoding the fields in the order as defined in the type. Generic F is the closure that will map the FIELDS to the set.

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_explicit_tag_and_constraints<D>( &mut self, tag: Tag, constraints: Constraints, ) -> Result<Option<D>, Self::Error>
where D: Decode,

Decode an extension addition with explicit tag in a SEQUENCE or SET.

Source

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

Decode a extension addition value with tag and constraints in a SEQUENCE or SET.

Source

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

Decode a extension addition group in a SEQUENCE or SET.

Const RC is the count of root components in a sequence. Const EC is the count of extension addition components in a sequence. Generic D is the type of the extension addition group.

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,

Decode an extension addition value in a SEQUENCE or SET.

Source

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

Decode an extension addition value with tag in a SEQUENCE or SET.

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_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_tag<D: Decode, F: FnOnce() -> D>( &mut self, tag: Tag, default_fn: F, ) -> Result<D, Self::Error>

Decode a DEFAULT value with tag 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

Source

fn decode_extension_addition_with_default_and_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 with tag and 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 Decoder for rasn::xer::de::Decoder

Source§

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

Source§

type Ok = ()

Source§

type Error = DecodeError

Source§

type AnyDecoder<const R: usize, const E: usize> = Decoder<'input>

Source§

impl<'input, const RFC: usize, const EFC: usize> Decoder for rasn::aper::Decoder<'input, RFC, EFC>

Source§

type Ok = ()

Source§

type Error = DecodeError

Source§

type AnyDecoder<const R: usize, const E: usize> = Decoder<'input, R, E>

Source§

impl<'input, const RFC: usize, const EFC: usize> Decoder for rasn::oer::de::Decoder<'input, RFC, EFC>

Source§

type Ok = ()

Source§

type Error = DecodeError

Source§

type AnyDecoder<const R: usize, const E: usize> = Decoder<'input, R, E>