Trait transformable::Decodable
source · 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§
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,
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.
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.