FromBytes

Trait FromBytes 

Source
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§

Source

type Error

The error type returned when parsing fails.

Required Methods§

Source

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.

Implementors§

Source§

impl<'de> FromBytes<'de> for Path

Source§

impl<'de> FromBytes<'de> for Paths