PebHeader

Struct PebHeader 

Source
pub struct PebHeader {
    pub magic: [u8; 4],
    pub erase_count: u32,
    pub status: PebStatus,
    pub peb_reserved: u8,
    pub version: u8,
    pub reserved: u8,
}
Expand description

PEB header.

This struct represents the on-flash header of a Physical Erase Block (PEB). It stores metadata required for flash management, wear leveling, and recovery logic.

The layout maps directly to struct peb_header_t in the original C implementation and must not be altered.

Fields§

§magic: [u8; 4]

Magic value identifying a valid PEB header. (NVDM)

This field is used to validate that the flash block contains a properly initialized PEB header.

§erase_count: u32

Erase count of the PEB.

This value tracks how many times the block has been erased and is typically used for wear-leveling decisions.

§status: PebStatus

Current status of the PEB.

This field encodes the lifecycle state of the PEB, such as virgin, active, transferring, or reclaiming.

§peb_reserved: u8

Reserved byte specific to PEB metadata.

This field is reserved for future use and should be preserved as-is to maintain binary compatibility.

§version: u8

Version of the PEB header format.

This field allows future extensions of the PEB header layout.

§reserved: u8

Reserved field.

This field is reserved and should be written as zero.

Trait Implementations§

Source§

impl BinarySize for PebHeader

Source§

fn binary_size() -> usize

Returns the binary size of the PebHeader in bytes.

Layout:

  • Fixed-size
  • Total: 12 bytes
Source§

impl Debug for PebHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PebHeader

Source§

fn default() -> Self

Creates a default PebHeader instance with invalid / erased values.

Default semantics:

  • magic: 0xFFFF_FFFF (invalid magic)
  • erase_count: 0
  • status: PebStatus::Virgin
  • peb_reserved: 0xFF
  • version: 0
  • reserved: 0
Source§

impl FromStream for PebHeader

Source§

fn read_from<R>(&mut self, reader: &mut R) -> Result<(), Error>
where R: Read,

Reads a PebHeader from a binary stream.

§Parameters
  • reader: A mutable reference to a reader implementing Read.
§Returns
  • Ok(()) if the header was successfully parsed.
  • Err(Error) if an I/O or conversion error occurs.
Source§

impl ToStream for PebHeader

Source§

fn write_to<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write,

Serializes the PebHeader to a binary stream.

§Parameters
  • writer: A mutable reference to a writer implementing Write.
§Returns
  • Ok(()) if serialization succeeds.
  • Err(Error) if an I/O error occurs.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.