Trait Decodable

Source
pub trait Decodable: Sized {
    type Target;
    type Error: Error + Sync + Send + 'static;

    // Required method
    fn decode(data: &[u8]) -> Result<Self::Target, Self::Error>;

    // Provided method
    fn decode_bytes(data: Bytes) -> Result<Self::Target, Self::Error> { ... }
}
Expand description

Determines how a response is decoded.

Required Associated Types§

Source

type Target

Target type to decode to.

Source

type Error: Error + Sync + Send + 'static

Error which can occur when attempting to decode data.

Required Methods§

Source

fn decode(data: &[u8]) -> Result<Self::Target, Self::Error>

Decode data from a byte slice.

Provided Methods§

Source

fn decode_bytes(data: Bytes) -> Result<Self::Target, Self::Error>

Decode data from Bytes.

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 ()

Source§

impl Decodable for Vec<u8>

Implementors§