DataItemHeader

Struct DataItemHeader 

Source
pub struct DataItemHeader {
    pub status: DataItemStatus,
    pub pnum: u8,
    pub reserved: u16,
    pub offset: u16,
    pub group_name_size: u8,
    pub data_item_name_size: u8,
    pub value_size: u16,
    pub index: u8,
    pub item_type: NvdmDataItemType,
    pub sequence_number: u32,
    pub hash_name: u32,
}
Expand description

Data item header.

This struct represents the on-flash header for an NVDM data item. It contains metadata describing the state, identity, size, and storage layout of the data item.

The layout and field meanings map directly to struct data_item_header_t in the original C implementation and are used by the NVDM storage and recovery logic.

Fields§

§status: DataItemStatus

Status of the data item.

This field encodes the lifecycle state of the data item, such as whether it is valid, being written, deleted, or empty.

§pnum: u8

Physical block number where the data item is stored.

This value typically identifies the PEB or page index associated with the data item.

§reserved: u16

Reserved field.

This field is reserved for future use and should be ignored. It is preserved to maintain binary compatibility with the on-flash data layout.

§offset: u16

Offset to the data item value.

This field specifies the byte offset from the start of the data item header to the actual value data.

§group_name_size: u8

Size of the group name, in bytes.

This value indicates the length of the group name associated with the data item.

§data_item_name_size: u8

Size of the data item name, in bytes.

This value indicates the length of the data item name associated with the data item.

§value_size: u16

Size of the data item value, in bytes.

This field specifies the length of the stored value data.

§index: u8

Index of the data item.

This field is typically used to distinguish between multiple instances of data items with the same name.

§item_type: NvdmDataItemType

Type of the data item value.

This field specifies how the value data should be interpreted, such as raw binary data or string data.

§sequence_number: u32

Sequence number of the data item.

This monotonically increasing value is used to determine the most recent version of a data item during recovery or scanning.

§hash_name: u32

Hash of the data item name.

This field stores a hash value derived from the group name and data item name, enabling faster lookups during NVDM operations.

Trait Implementations§

Source§

impl BinarySize for DataItemHeader

Source§

fn binary_size() -> usize

Returns the binary size of the DataItemHeader in bytes.

Layout size:

  • Fixed-size, packed
  • Total: 20 bytes
Source§

impl Debug for DataItemHeader

Source§

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

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

impl Default for DataItemHeader

Source§

fn default() -> Self

Creates a default DataItemHeader instance with safe invalid values.

Default semantics:

  • status: DataItemStatus::Empty (unused slot)
  • pnum: 0xFF (invalid physical block number)
  • reserved: 0
  • offset: 0
  • group_name_size: 0
  • data_item_name_size: 0
  • value_size: 0
  • index: 0
  • item_type: NvdmDataItemType::RawData
  • sequence_number: 0
  • hash_name: 0
Source§

impl FromStream for DataItemHeader

Source§

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

Reads a DataItemHeader 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 DataItemHeader

Source§

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

Serializes the DataItemHeader 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.