pub trait DeserializableSlice<const N: usize>: Serializable<N> {
// Provided methods
fn from_slice(buf: &[u8]) -> Result<Self, Self::Error>
where Self: Sized,
Self::Error: BadLength { ... }
fn from_reader<R>(buf: &mut R) -> Result<Self, Self::Error>
where R: Read,
Self: Sized,
Self::Error: BadLength { ... }
}Expand description
An optional trait used to implement DeserializableSlice::from_slice on
top of types that use the Serializable trait.
The default implementation makes use of Serializable trait to provide
the necessary deserialization functionality without additional code from the
consumer.
Provided Methods§
Sourcefn from_slice(buf: &[u8]) -> Result<Self, Self::Error>
fn from_slice(buf: &[u8]) -> Result<Self, Self::Error>
Sourcefn from_reader<R>(buf: &mut R) -> Result<Self, Self::Error>
fn from_reader<R>(buf: &mut R) -> Result<Self, Self::Error>
Deserialize the type by reading exactly N bytes from a reader.
Successful short reads are retried. If the reader makes no progress or
returns an error before filling the buffer, a bad-length error is
returned. The bytes read are removed from the reader, including bytes
read before an error or end of input.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".