pub trait FromBytes {
// Required method
fn read_le<R>(reader: R) -> Result<Self, Error>
where R: Read,
Self: Sized;
// Provided methods
fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>
where Self: Sized { ... }
fn from_bytes_le_unchecked(bytes: &[u8]) -> Result<Self, Error>
where Self: Sized { ... }
fn read_le_unchecked<R>(reader: R) -> Result<Self, Error>
where R: Read,
Self: Sized { ... }
fn read_le_with_unchecked<R>(
reader: R,
unchecked: bool,
) -> Result<Self, Error>
where R: Read,
Self: Sized { ... }
}Required Methods§
Provided Methods§
Sourcefn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>where
Self: Sized,
fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>where
Self: Sized,
Returns Self from a byte array in little-endian order.
Sourcefn from_bytes_le_unchecked(bytes: &[u8]) -> Result<Self, Error>where
Self: Sized,
fn from_bytes_le_unchecked(bytes: &[u8]) -> Result<Self, Error>where
Self: Sized,
Same behavior as Self::from_bytes_le but avoids costly checks.
This shall only be called when deserializing from a trusted source, such as local storage.
Returns Self from a byte array in little-endian order.
Sourcefn read_le_unchecked<R>(reader: R) -> Result<Self, Error>
fn read_le_unchecked<R>(reader: R) -> Result<Self, Error>
Same behavior as Self::read_le but avoids costly checks.
This shall only be called when deserializing from a trusted source, such as local storage.
The default implementation simply calls Self::read_le.