pub trait Encode: AsnType {
// Required method
fn encode_with_tag_and_constraints<E: Encoder>(
&self,
encoder: &mut E,
tag: Tag,
constraints: Constraints<'_>,
) -> Result<(), E::Error>;
// Provided methods
fn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error> { ... }
fn encode_with_tag<E: Encoder>(
&self,
encoder: &mut E,
tag: Tag,
) -> Result<(), E::Error> { ... }
fn encode_with_constraints<E: Encoder>(
&self,
encoder: &mut E,
constraints: Constraints<'_>,
) -> Result<(), E::Error> { ... }
}Expand description
A data type that can be encoded to a ASN.1 data format.
Required Methods§
fn encode_with_tag_and_constraints<E: Encoder>( &self, encoder: &mut E, tag: Tag, constraints: Constraints<'_>, ) -> Result<(), E::Error>
Provided Methods§
sourcefn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error>
fn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), E::Error>
Encodes self’s data into the given Encoder.
Note for implementors You typically do not need to implement this.
The default implementation will call Encode::encode_with_tag with
your types associated AsnType::TAG. 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 encode.
sourcefn encode_with_tag<E: Encoder>(
&self,
encoder: &mut E,
tag: Tag,
) -> Result<(), E::Error>
fn encode_with_tag<E: Encoder>( &self, encoder: &mut E, tag: Tag, ) -> Result<(), E::Error>
Encode this value with tag into the given 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.
fn encode_with_constraints<E: Encoder>( &self, encoder: &mut E, constraints: Constraints<'_>, ) -> Result<(), E::Error>
Object Safety§
This trait is not object safe.