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§
Sourcefn encode_with_tag_and_constraints<'b, E: Encoder<'b>>(
&self,
encoder: &mut E,
tag: Tag,
constraints: Constraints,
identifier: Identifier,
) -> Result<(), E::Error>
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§
Sourcefn encode<'b, E: Encoder<'b>>(&self, encoder: &mut E) -> Result<(), E::Error>
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.
Sourcefn encode_with_tag<'b, E: Encoder<'b>>(
&self,
encoder: &mut E,
tag: Tag,
) -> Result<(), E::Error>
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.
Sourcefn encode_with_identifier<'b, E: Encoder<'b>>(
&self,
encoder: &mut E,
identifier: Identifier,
) -> Result<(), E::Error>
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.
Sourcefn encode_with_tag_and_identifier<'b, E: Encoder<'b>>(
&self,
encoder: &mut E,
tag: Tag,
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>
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.
Sourcefn encode_with_constraints<'b, E: Encoder<'b>>(
&self,
encoder: &mut E,
constraints: Constraints,
) -> Result<(), E::Error>
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.
Sourcefn encode_with_constraints_and_identifier<'b, E: Encoder<'b>>(
&self,
encoder: &mut E,
constraints: Constraints,
identifier: Identifier,
) -> Result<(), E::Error>
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.