Trait bcder::encode::PrimitiveContent
source · pub trait PrimitiveContent {
const TAG: Tag;
fn encoded_len(&self, mode: Mode) -> usize;
fn write_encoded<W: Write>(
&self,
mode: Mode,
target: &mut W
) -> Result<(), Error>;
fn to_encoded_bytes(&self, mode: Mode) -> Bytes { ... }
fn encode(&self) -> Primitive<'_, Self> { ... }
fn encode_as(&self, tag: Tag) -> Primitive<'_, Self> { ... }
}
Expand description
A type that is encoded as a primitive value.
This trait should be implemented for types that use primitive encoding.
It defines, how the content octets of a single primitive value containing
a value of the type are to be created. As a consequence, these types
gain the encode
and encode_as
methods from their implementation
of this trait.
Required Associated Constants§
Required Methods§
sourcefn encoded_len(&self, mode: Mode) -> usize
fn encoded_len(&self, mode: Mode) -> usize
Returns the length of the encoded content of this type.
Provided Methods§
sourcefn to_encoded_bytes(&self, mode: Mode) -> Bytes
fn to_encoded_bytes(&self, mode: Mode) -> Bytes
Encodes the value to bytes (useful when you need to sign a structure)