Trait Encoder

Source
pub trait Encoder<'encoder, const RCL: usize = 0, const ECL: usize = 0> {
    type Ok;
    type Error: Error + Into<EncodeError> + From<EncodeError>;
    type AnyEncoder<'other_encoder, const R: usize, const E: usize>: Encoder<'other_encoder, RCL, ECL, Ok = Self::Ok, Error = Self::Error>;

Show 42 methods // Required methods fn codec(&self) -> Codec; fn encode_any( &mut self, tag: Tag, value: &Any, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_bool( &mut self, tag: Tag, value: bool, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_bit_string( &mut self, tag: Tag, constraints: Constraints, value: &BitStr, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_enumerated<E: Enumerated>( &mut self, tag: Tag, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_object_identifier( &mut self, tag: Tag, value: &[u32], identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_integer<I: IntegerType>( &mut self, tag: Tag, constraints: Constraints, value: &I, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_real<R: RealType>( &mut self, tag: Tag, constraints: Constraints, value: &R, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_null( &mut self, tag: Tag, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_octet_string( &mut self, tag: Tag, constraints: Constraints, value: &[u8], identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_general_string( &mut self, tag: Tag, constraints: Constraints, value: &GeneralString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_graphic_string( &mut self, tag: Tag, constraints: Constraints, value: &GraphicString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_utf8_string( &mut self, tag: Tag, constraints: Constraints, value: &str, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_visible_string( &mut self, tag: Tag, constraints: Constraints, value: &VisibleString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_ia5_string( &mut self, tag: Tag, constraints: Constraints, value: &Ia5String, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_printable_string( &mut self, tag: Tag, constraints: Constraints, value: &PrintableString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_numeric_string( &mut self, tag: Tag, constraints: Constraints, value: &NumericString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_teletex_string( &mut self, tag: Tag, constraints: Constraints, value: &TeletexString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_bmp_string( &mut self, tag: Tag, constraints: Constraints, value: &BmpString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_generalized_time( &mut self, tag: Tag, value: &GeneralizedTime, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_utc_time( &mut self, tag: Tag, value: &UtcTime, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_date( &mut self, tag: Tag, value: &Date, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_explicit_prefix<V: Encode>( &mut self, tag: Tag, value: &V, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_sequence<'b, const RC: usize, const EC: usize, C, F>( &'b mut self, tag: Tag, encoder_scope: F, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> where C: Constructed<RC, EC>, F: FnOnce(&mut Self::AnyEncoder<'b, RC, EC>) -> Result<(), Self::Error>; fn encode_sequence_of<E: Encode>( &mut self, tag: Tag, value: &[E], constraints: Constraints, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_set<'b, const RC: usize, const EC: usize, C, F>( &'b mut self, tag: Tag, value: F, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> where C: Constructed<RC, EC>, F: FnOnce(&mut Self::AnyEncoder<'b, RC, EC>) -> Result<(), Self::Error>; fn encode_set_of<E: Encode + Eq + Hash>( &mut self, tag: Tag, value: &SetOf<E>, constraints: Constraints, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_some<E: Encode>( &mut self, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_some_with_tag_and_constraints<E: Encode>( &mut self, tag: Tag, constraints: Constraints, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_none<E: Encode>( &mut self, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_none_with_tag( &mut self, tag: Tag, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_choice<E: Encode + Choice>( &mut self, constraints: Constraints, tag: Tag, encode_fn: impl FnOnce(&mut Self) -> Result<Tag, Self::Error>, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_extension_addition<E: Encode>( &mut self, tag: Tag, constraints: Constraints, value: E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>; fn encode_extension_addition_group<const RC: usize, const EC: usize, E>( &mut self, value: Option<&E>, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> where E: Encode + Constructed<RC, EC>; // Provided methods fn encode_or_default<E: Encode + Default + PartialEq>( &mut self, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> { ... } fn encode_with_tag_or_default<E: Encode + Default + PartialEq>( &mut self, tag: Tag, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> { ... } fn encode_some_with_tag<E: Encode>( &mut self, tag: Tag, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> { ... } fn encode_default<E: Encode + PartialEq>( &mut self, value: &E, default: impl FnOnce() -> E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> { ... } fn encode_default_with_tag<E: Encode + PartialEq>( &mut self, tag: Tag, value: &E, default: impl FnOnce() -> E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> { ... } fn encode_default_with_explicit_prefix<E: Encode + PartialEq>( &mut self, tag: Tag, value: &E, default: impl FnOnce() -> E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> { ... } fn encode_default_with_tag_and_constraints<E: Encode + PartialEq>( &mut self, tag: Tag, constraints: Constraints, value: &E, default: impl FnOnce() -> E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> { ... } fn encode_default_with_constraints<E: Encode + PartialEq>( &mut self, constraints: Constraints, value: &E, default: impl FnOnce() -> E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error> { ... }
}
Expand description

A data format encode 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<EncodeError> + From<EncodeError>

The associated error type returned on failure.

Source

type AnyEncoder<'other_encoder, const R: usize, const E: usize>: Encoder<'other_encoder, RCL, ECL, Ok = Self::Ok, Error = Self::Error>

Helper type for encoding recursive Encoder instances with different RCL or ECL values.

Required Methods§

Source

fn codec(&self) -> Codec

Returns codec variant of Codec that current encoder is encoding.

Source

fn encode_any( &mut self, tag: Tag, value: &Any, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode an unknown ASN.1 value.

Source

fn encode_bool( &mut self, tag: Tag, value: bool, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a BOOL value.

Source

fn encode_bit_string( &mut self, tag: Tag, constraints: Constraints, value: &BitStr, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a BIT STRING value.

Source

fn encode_enumerated<E: Enumerated>( &mut self, tag: Tag, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a ENUMERATED value.

Source

fn encode_object_identifier( &mut self, tag: Tag, value: &[u32], identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a OBJECT IDENTIFIER value.

Source

fn encode_integer<I: IntegerType>( &mut self, tag: Tag, constraints: Constraints, value: &I, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a INTEGER value.

Source

fn encode_real<R: RealType>( &mut self, tag: Tag, constraints: Constraints, value: &R, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a REAL value.

Source

fn encode_null( &mut self, tag: Tag, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a NULL value.

Source

fn encode_octet_string( &mut self, tag: Tag, constraints: Constraints, value: &[u8], identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a OCTET STRING value.

Source

fn encode_general_string( &mut self, tag: Tag, constraints: Constraints, value: &GeneralString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a GeneralString value.

Source

fn encode_graphic_string( &mut self, tag: Tag, constraints: Constraints, value: &GraphicString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a GraphicString value.

Source

fn encode_utf8_string( &mut self, tag: Tag, constraints: Constraints, value: &str, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a Utf8String value.

Source

fn encode_visible_string( &mut self, tag: Tag, constraints: Constraints, value: &VisibleString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a VisibleString value.

Source

fn encode_ia5_string( &mut self, tag: Tag, constraints: Constraints, value: &Ia5String, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a Ia5String value.

Source

fn encode_printable_string( &mut self, tag: Tag, constraints: Constraints, value: &PrintableString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a Ia5String value.

Source

fn encode_numeric_string( &mut self, tag: Tag, constraints: Constraints, value: &NumericString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a NumericString value.

Source

fn encode_teletex_string( &mut self, tag: Tag, constraints: Constraints, value: &TeletexString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a TeletexString value.

Source

fn encode_bmp_string( &mut self, tag: Tag, constraints: Constraints, value: &BmpString, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a BmpString value.

Source

fn encode_generalized_time( &mut self, tag: Tag, value: &GeneralizedTime, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a GeneralizedTime value.

Source

fn encode_utc_time( &mut self, tag: Tag, value: &UtcTime, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a UtcTime value.

Source

fn encode_date( &mut self, tag: Tag, value: &Date, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a ‘Date’ value.

Source

fn encode_explicit_prefix<V: Encode>( &mut self, tag: Tag, value: &V, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a explicitly tagged value.

Source

fn encode_sequence<'b, const RC: usize, const EC: usize, C, F>( &'b mut self, tag: Tag, encoder_scope: F, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>
where C: Constructed<RC, EC>, F: FnOnce(&mut Self::AnyEncoder<'b, RC, EC>) -> Result<(), Self::Error>,

Encode a SEQUENCE value.

Const RC is the count of root components in a sequence. Const EC is the count of extension addition components in a sequence. Generic C is the sequence type. Generic F is the closure that will encode the sequence by encoding the fields in the order as defined in the type. NOTE: If you implement this manually, make sure to encode fields in the same order and pass the correct count of fields.

Source

fn encode_sequence_of<E: Encode>( &mut self, tag: Tag, value: &[E], constraints: Constraints, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a SEQUENCE OF value.

Source

fn encode_set<'b, const RC: usize, const EC: usize, C, F>( &'b mut self, tag: Tag, value: F, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>
where C: Constructed<RC, EC>, F: FnOnce(&mut Self::AnyEncoder<'b, RC, EC>) -> Result<(), Self::Error>,

Encode a SET value.

Const RC is the count of root components in a set. Const EC is the count of extension addition components in a set. Generic C is the set type. Generic F is the closure that will encode the set fields in appearance order. Encoder will rearrange them in the correct order later. NOTE: If you implement this manually, make sure to encode fields in the same order and pass the correct count of fields.

Source

fn encode_set_of<E: Encode + Eq + Hash>( &mut self, tag: Tag, value: &SetOf<E>, constraints: Constraints, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a SET OF value.

Source

fn encode_some<E: Encode>( &mut self, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the present value of an optional field.

Source

fn encode_some_with_tag_and_constraints<E: Encode>( &mut self, tag: Tag, constraints: Constraints, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the present value of an optional field.

Source

fn encode_none<E: Encode>( &mut self, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the absent value of an optional field.

Source

fn encode_none_with_tag( &mut self, tag: Tag, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the absent value with tag of an optional field.

Source

fn encode_choice<E: Encode + Choice>( &mut self, constraints: Constraints, tag: Tag, encode_fn: impl FnOnce(&mut Self) -> Result<Tag, Self::Error>, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a CHOICE value.

Source

fn encode_extension_addition<E: Encode>( &mut self, tag: Tag, constraints: Constraints, value: E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode a extension addition value.

Source

fn encode_extension_addition_group<const RC: usize, const EC: usize, E>( &mut self, value: Option<&E>, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>
where E: Encode + Constructed<RC, EC>,

Encode a extension addition group value.

Const RC is the count of root components in sequence or set. Const EC is the count of extension components in sequence or set. E is the type of the extension addition group value being encoded.

Provided Methods§

Source

fn encode_or_default<E: Encode + Default + PartialEq>( &mut self, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the value a field or skip if it matches the default..

Source

fn encode_with_tag_or_default<E: Encode + Default + PartialEq>( &mut self, tag: Tag, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the present value of an optional field.

Source

fn encode_some_with_tag<E: Encode>( &mut self, tag: Tag, value: &E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the present value of an optional field.

Source

fn encode_default<E: Encode + PartialEq>( &mut self, value: &E, default: impl FnOnce() -> E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the present value of an optional field.

Source

fn encode_default_with_tag<E: Encode + PartialEq>( &mut self, tag: Tag, value: &E, default: impl FnOnce() -> E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the present value of an optional field.

Source

fn encode_default_with_explicit_prefix<E: Encode + PartialEq>( &mut self, tag: Tag, value: &E, default: impl FnOnce() -> E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the preset value of an optional field using Explicit Tags

Source

fn encode_default_with_tag_and_constraints<E: Encode + PartialEq>( &mut self, tag: Tag, constraints: Constraints, value: &E, default: impl FnOnce() -> E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the present value of an optional field.

Source

fn encode_default_with_constraints<E: Encode + PartialEq>( &mut self, constraints: Constraints, value: &E, default: impl FnOnce() -> E, identifier: Identifier, ) -> Result<Self::Ok, Self::Error>

Encode the present constrained value of an optional field.

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 Encoder<'_> for rasn::ber::enc::Encoder

Source§

type Ok = ()

Source§

type Error = EncodeError

Source§

type AnyEncoder<'this, const R: usize, const E: usize> = Encoder

Source§

impl Encoder<'_> for rasn::jer::enc::Encoder

Source§

type Ok = ()

Source§

type Error = EncodeError

Source§

type AnyEncoder<'this, const R: usize, const E: usize> = Encoder

Source§

impl Encoder<'_> for rasn::xer::enc::Encoder

Source§

type Ok = ()

Source§

type Error = EncodeError

Source§

type AnyEncoder<'this, const R: usize, const E: usize> = Encoder

Source§

impl<'buffer, const RFC: usize, const EFC: usize> Encoder<'buffer> for rasn::oer::enc::Encoder<'buffer, RFC, EFC>

Source§

type Ok = ()

Source§

type Error = EncodeError

Source§

type AnyEncoder<'this, const R: usize, const E: usize> = Encoder<'this, R, E>

Source§

impl<const RFC: usize, const EFC: usize> Encoder<'_> for rasn::aper::Encoder<RFC, EFC>

Source§

type Ok = ()

Source§

type Error = EncodeError

Source§

type AnyEncoder<'this, const R: usize, const E: usize> = Encoder<R, E>