Trait Encodable

Source
pub trait Encodable {
    // Required methods
    fn encoded_length(&self) -> Result<Length>;
    fn encode(&self, encoder: &mut Encoder<'_>) -> Result<()>;

    // Provided method
    fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]> { ... }
}
Expand description

Encoding trait.

Encode into encoder, which essentially is a mutable slice of bytes.

Additionally, the encoded length needs to be known without actually encoding.

Required Methods§

Source

fn encoded_length(&self) -> Result<Length>

Compute the length of this value in bytes when encoded as BER-TLV

Source

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

Encode this value as BER-TLV using the provided Encoder.

Provided Methods§

Source

fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8]>

Encode this value to the provided byte slice, returning a sub-slice containing the encoded message.

Implementations on Foreign Types§

Source§

impl Encodable for &[u8]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 0]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 1]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 2]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 3]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 4]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 5]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 6]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 7]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 8]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 9]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 10]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 11]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 12]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 13]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 14]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 15]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 16]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 17]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 18]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 19]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 20]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 21]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 22]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 23]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 24]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 25]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 26]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 27]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 28]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 29]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 30]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 31]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl Encodable for [u8; 32]

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Source§

impl<T> Encodable for Option<T>
where T: Encodable,

Source§

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

Encode this value as BER-TLV using the provided Encoder.

Source§

fn encoded_length(&self) -> Result<Length>

Implementors§

Source§

impl Encodable for Length

Source§

impl Encodable for SimpleTag

Source§

impl Encodable for Tag

Source§

impl<E, T> Encodable for TaggedValue<&E, T>
where E: Encodable, T: Copy + Encodable,

Source§

impl<T> Encodable for TaggedSlice<'_, T>
where T: Copy + Encodable,

Source§

impl<TaggedContainer> Encodable for TaggedContainer
where TaggedContainer: Tagged + Container,