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

    // Required methods
    fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
       where Self: Sized;
    fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
       where Self: Sized;
    fn decode_from_async_reader<R: AsyncRead + Send + Unpin>(
        reader: &mut R
    ) -> impl Future<Output = Result<(usize, Self)>> + Send
       where Self: Sized;
}
Available on crate feature std only.
Expand description

The type can transform its representation from byte form to struct.

Required Associated Types§

source

type Error: Error + Send + Sync + 'static

The error type returned when encoding or decoding fails.

Required Methods§

source

fn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>
where Self: Sized,

Decodes the value from the given buffer received over the wire.

Returns the number of bytes read from the buffer and the struct.

source

fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>
where Self: Sized,

Decodes the value from the given reader received over the wire.

Returns the number of bytes read from the reader and the struct.

source

fn decode_from_async_reader<R: AsyncRead + Send + Unpin>( reader: &mut R ) -> impl Future<Output = Result<(usize, Self)>> + Send
where Self: Sized,

Available on crate feature async only.

Decodes the value from the given async reader received over the wire.

Returns the number of bytes read from the reader and the struct.

Implementors§