Skip to main content

Decode

Trait Decode 

Source
pub trait Decode: Sized {
    // Required method
    fn decode(decoder: &mut impl Decoder) -> Result<Self, DecodeError>;

    // Provided method
    fn decode_trailing(
        decoder: &mut impl Decoder,
    ) -> Result<Option<Self>, DecodeError> { ... }
}
Expand description

Deserializes a value from an OpenTimestamps-compatible byte stream.

Required Methods§

Source

fn decode(decoder: &mut impl Decoder) -> Result<Self, DecodeError>

Provided Methods§

Source

fn decode_trailing( decoder: &mut impl Decoder, ) -> Result<Option<Self>, DecodeError>

Decodes a trailing optional value implementing the Decode trait.

This treats any UnexpectedEof error as an indication that the value is absent, returning Ok(None).

If the implementor returns UnexpectedEof for any reason other than the absence of the value, it should also override this method to avoid masking the error as Ok(None).

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 Decode for Chain

Source§

fn decode(decoder: &mut impl Decoder) -> Result<Self, DecodeError>

Source§

impl Decode for Address

Source§

fn decode(decoder: &mut impl Decoder) -> Result<Self, DecodeError>

Source§

impl<const N: usize> Decode for FixedBytes<N>

Source§

fn decode(decoder: &mut impl Decoder) -> Result<Self, DecodeError>

Implementors§