pub trait FromBytes: Sized {
// Required method
fn from_bytes(buf: &[u8]) -> Result<(Self, usize), ParseError>;
}Expand description
Parse a type from a byte slice, returning the parsed value and the number of bytes consumed.
Unlike ReadFromBytes, this trait does not require std::io or the byteorder crate.
It operates directly on &[u8] slices, making it suitable for no_std environments
and packet capture analysis.
Required Methods§
Sourcefn from_bytes(buf: &[u8]) -> Result<(Self, usize), ParseError>
fn from_bytes(buf: &[u8]) -> Result<(Self, usize), ParseError>
Parse from the given byte slice. Returns the parsed value and the
number of bytes consumed from the front of buf.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.