Trait Encode

Source
pub trait Encode: AsnType {
    // Required method
    fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>(
        &self,
        encoder: &mut E,
        tag: Tag,
        constraints: Constraints,
        identifier: Identifier,
    ) -> Result<(), E::Error>;

    // Provided methods
    fn encode<'b, E: Encoder<'b>>(
        &self,
        encoder: &mut E,
    ) -> Result<(), E::Error> { ... }
    fn encode_with_tag<'b, E: Encoder<'b>>(
        &self,
        encoder: &mut E,
        tag: Tag,
    ) -> Result<(), E::Error> { ... }
    fn encode_with_identifier<'b, E: Encoder<'b>>(
        &self,
        encoder: &mut E,
        identifier: Identifier,
    ) -> Result<(), E::Error> { ... }
    fn encode_with_tag_and_identifier<'b, E: Encoder<'b>>(
        &self,
        encoder: &mut E,
        tag: Tag,
        identifier: Identifier,
    ) -> Result<(), E::Error> { ... }
    fn encode_with_constraints<'b, E: Encoder<'b>>(
        &self,
        encoder: &mut E,
        constraints: Constraints,
    ) -> Result<(), E::Error> { ... }
    fn encode_with_constraints_and_identifier<'b, E: Encoder<'b>>(
        &self,
        encoder: &mut E,
        constraints: Constraints,
        identifier: Identifier,
    ) -> Result<(), E::Error> { ... }
}
Expand description

A data type that can be encoded to a ASN.1 data format.

Required Methods§

Source

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Encode this value with tag into the given crate::Encoder with the constraints the values this is allowed to encode into.

Note For CHOICE and other types that cannot be implicitly tagged this will explicitly tag the value, for all other types, it will implicitly tag the value.

Provided Methods§

Source

fn encode<'b, E: Encoder<'b>>(&self, encoder: &mut E) -> Result<(), E::Error>

Encodes self’s data into the given crate::Encoder.

Note for implementors You typically do not need to implement this. The default implementation will call Encode::encode_with_tag_and_constraints with your types associated AsnType::TAG and AsnType::CONSTRAINTS. You should only ever need to implement this if you have a type that cannot be implicitly tagged, such as a CHOICE type, in which case you want to implement encoding in Self::encode.

Source

fn encode_with_tag<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, ) -> Result<(), E::Error>

Encode this value with tag into the given crate::Encoder.

Note For CHOICE and other types that cannot be implicitly tagged this will explicitly tag the value, for all other types, it will implicitly tag the value.

Source

fn encode_with_identifier<'b, E: Encoder<'b>>( &self, encoder: &mut E, identifier: Identifier, ) -> Result<(), E::Error>

Encode this value with identifier into the given crate::Encoder.

Note For CHOICE and other types that cannot be implicitly tagged this will explicitly tag the value, for all other types, it will implicitly tag the value.

Source

fn encode_with_tag_and_identifier<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, identifier: Identifier, ) -> Result<(), E::Error>

Encode this value with tag and identifier into the given crate::Encoder.

Note For CHOICE and other types that cannot be implicitly tagged this will explicitly tag the value, for all other types, it will implicitly tag the value.

Source

fn encode_with_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, constraints: Constraints, ) -> Result<(), E::Error>

Encode this value into the given crate::Encoder with the constraints the values this is allowed to encode into.

Note For CHOICE and other types that cannot be implicitly tagged this will explicitly tag the value, for all other types, it will implicitly tag the value.

Source

fn encode_with_constraints_and_identifier<'b, E: Encoder<'b>>( &self, encoder: &mut E, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Encode this value into the given crate::Encoder with identifier and the constraints the values this is allowed to encode into.

Note For CHOICE and other types that cannot be implicitly tagged this will explicitly tag the value, for all other types, it will implicitly tag the value.

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.

Implementations on Foreign Types§

Source§

impl Encode for &str

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for bool

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, _: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for f32

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for f64

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for i8

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for i16

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for i32

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for i64

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for i128

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for isize

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for u8

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for u16

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for u32

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for u64

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for u128

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for ()

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, _: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for usize

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl Encode for BigInt

Source§

fn encode_with_tag_and_constraints<'b, E: Encoder<'b>>( &self, encoder: &mut E, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), E::Error>

Source§

impl<E: Encode> Encode for Option<E>

Source§

fn encode<'b, EN: Encoder<'b>>(&self, encoder: &mut EN) -> Result<(), EN::Error>

Source§

fn encode_with_tag<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, tag: Tag, ) -> Result<(), EN::Error>

Source§

fn encode_with_tag_and_identifier<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, tag: Tag, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

fn encode_with_constraints<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, constraints: Constraints, ) -> Result<(), EN::Error>

Source§

fn encode_with_constraints_and_identifier<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, constraints: Constraints, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

fn encode_with_identifier<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

fn encode_with_tag_and_constraints<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

impl<E: Encode> Encode for &E

Source§

fn encode<'b, EN: Encoder<'b>>(&self, encoder: &mut EN) -> Result<(), EN::Error>

Source§

fn encode_with_tag<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, tag: Tag, ) -> Result<(), EN::Error>

Source§

fn encode_with_tag_and_identifier<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, tag: Tag, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

fn encode_with_identifier<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

fn encode_with_constraints<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, constraints: Constraints, ) -> Result<(), EN::Error>

Source§

fn encode_with_constraints_and_identifier<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, constraints: Constraints, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

fn encode_with_tag_and_constraints<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

impl<E: Encode> Encode for Box<E>

Source§

fn encode<'b, EN: Encoder<'b>>(&self, encoder: &mut EN) -> Result<(), EN::Error>

Source§

fn encode_with_tag<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, tag: Tag, ) -> Result<(), EN::Error>

Source§

fn encode_with_constraints<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, constraints: Constraints, ) -> Result<(), EN::Error>

Source§

fn encode_with_identifier<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

fn encode_with_tag_and_constraints<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

impl<E: Encode> Encode for Vec<E>

Source§

fn encode_with_tag_and_constraints<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

impl<E: Encode, const N: usize> Encode for [E; N]

Source§

fn encode_with_tag_and_constraints<'b, EN: Encoder<'b>>( &self, encoder: &mut EN, tag: Tag, constraints: Constraints, identifier: Identifier, ) -> Result<(), EN::Error>

Source§

impl<T: AsnType> Encode for PhantomData<T>

Implementors§