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§
Provided Methods§
sourcefn from_bytes(bytes: &'a [u8]) -> Result<Self>
fn from_bytes(bytes: &'a [u8]) -> Result<Self>
Parse Self from the provided byte slice.
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl<'a, T> Decodable<'a> for Option<T>
impl<'a, T> Decodable<'a> for Option<T>
This implementation is quite gotcha-y, since only one byte is peeked.
It should evaluate to the desired tag via Tag::try_from(byte)?.