pub trait FromBytes<'de>: Sized {
type Error;
// Required method
fn from_bytes(bytes: &'de [u8]) -> Result<Self, Self::Error>;
}Expand description
Trait for parsing structures from raw byte data.
This trait provides a standardized interface for converting byte slices into structured data types, commonly used for parsing UEFI data structures.
Required Associated Types§
Required Methods§
Sourcefn from_bytes(bytes: &'de [u8]) -> Result<Self, Self::Error>
fn from_bytes(bytes: &'de [u8]) -> Result<Self, Self::Error>
Parse a structure from raw bytes.
§Arguments
bytes- The byte slice to parse from
§Returns
Returns the parsed structure on success.
§Errors
Returns an error if the byte data is invalid, incomplete, or cannot be parsed into the target structure. This can occur when:
- The input is too short for the expected structure
- The data format is invalid or corrupted
- Required fields contain invalid values
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.