Decodable

Trait Decodable 

Source
pub trait Decodable<'a>: Sized {
    // Required method
    fn decode(decoder: &mut Decoder<'a>) -> Result<Self>;

    // Provided method
    fn from_bytes(bytes: &'a [u8]) -> Result<Self> { ... }
}
Expand description

Decoding trait.

Decode out of decoder, which essentially is a slice of bytes.

One way to implement this trait is to implement TryFrom<TaggedSlice<'_>, Error = Error>.

Required Methods§

Source

fn decode(decoder: &mut Decoder<'a>) -> Result<Self>

Attempt to decode this message using the provided decoder.

Provided Methods§

Source

fn from_bytes(bytes: &'a [u8]) -> Result<Self>

Parse Self from the provided byte slice.

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 Decodable<'_> for [u8; 0]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 1]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 2]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 3]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 4]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 5]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 6]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 7]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 8]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 9]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 10]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 11]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 12]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 13]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 14]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 15]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 16]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 17]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 18]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 19]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 20]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 21]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 22]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 23]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 24]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 25]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 26]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 27]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 28]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 29]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 30]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 31]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl Decodable<'_> for [u8; 32]

Source§

fn decode(decoder: &mut Decoder<'_>) -> Result<Self>

Source§

impl<'a, T> Decodable<'a> for Option<T>
where T: Decodable<'a> + Tagged,

This implementation is quite gotcha-y, since only one byte is peeked.

It should evaluate to the desired tag via Tag::try_from(byte)?.

Source§

fn decode(decoder: &mut Decoder<'a>) -> Result<Option<T>>

Implementors§

Source§

impl Decodable<'_> for Length

Source§

impl Decodable<'_> for SimpleTag

Source§

impl Decodable<'_> for Tag

Source§

impl<'a, T> Decodable<'a> for TaggedSlice<'a, T>
where T: Decodable<'a> + TagLike,

Source§

impl<'a, X> Decodable<'a> for X
where X: TryFrom<TaggedSlice<'a>, Error = Error>,