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;
}Expand description
The type can transform its representation from byte form to struct.
Required Associated Types§
Required Methods§
Sourcefn decode(src: &[u8]) -> Result<(usize, Self), Self::Error>where
Self: Sized,
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.
Sourcefn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>where
Self: Sized,
Available on crate feature std only.
fn decode_from_reader<R: Read>(reader: &mut R) -> Result<(usize, Self)>where
Self: Sized,
std only.Decodes the value from the given reader received over the wire.
Returns the number of bytes read from the reader and the struct.
Sourcefn decode_from_async_reader<R: AsyncRead + Send + Unpin>(
reader: &mut R,
) -> impl Future<Output = Result<(usize, Self)>> + Sendwhere
Self: Sized,
Available on crate feature async only.
fn decode_from_async_reader<R: AsyncRead + Send + Unpin>(
reader: &mut R,
) -> impl Future<Output = Result<(usize, Self)>> + Sendwhere
Self: Sized,
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.