pub trait FromBytes {
type Error;
// Required method
fn from_bytes(_: &[u8]) -> Result<&Self, Self::Error>;
}
Expand description
A cheap conversion from a byte slice to typed data.
Given a reference to a byte slice, returns a different view of the same
data. No allocation is performed, however the underlying data might be
checked for correctness (for example when converting to str
).
See also the ToBytes
trait.
Required Associated Types§
Required Methods§
sourcefn from_bytes(_: &[u8]) -> Result<&Self, Self::Error>
fn from_bytes(_: &[u8]) -> Result<&Self, Self::Error>
Tries to convert the provided byte slice into a different type.
Object Safety§
This trait is not object safe.