NVDM

Struct NVDM 

Source
pub struct NVDM { /* private fields */ }
Expand description

Represents the Non-Volatile Data Management (NVDM) system, which manages user data storage in flash memory.

NVDM supports data retention after power off and organizes data items into groups, enabling classification and orderly management of items.

Implementations§

Source§

impl NVDM

Source

pub fn from_peb_size(peb_size: u32) -> Self

Constructs a new NVDM with the specified physical erase block (PEB) size.

Other fields are initialized with default values.

§Parameters
  • peb_size: The size of a physical erase block in bytes.
§Returns
  • An NVDM instance configured with the given PEB size.
Source

pub fn nvdm_port_get_peb_address(&self, pnum: u32, offset: u32) -> u32

Computes the flash address based on PEB number and offset within the PEB.

§Parameters
  • pnum: The physical erase block number.
  • offset: The offset within the PEB.
§Returns
  • The calculated flash address as a u32.
Source

pub fn get_item( &self, group: &str, name: &str, status: DataItemStatus, ) -> Option<&DataItem>

Retrieves a reference to a data item matching the specified group, name, and status.

§Parameters
  • group: The group name to match.
  • name: The item name to match.
  • status: The status of the data item to match.
§Returns
  • Some(&DataItem) if an item matching all criteria exists.
  • None if no matching item is found.
Source

pub fn get_items_by_group( &self, group: &str, status: DataItemStatus, ) -> Vec<&DataItem>

Retrieves all data items within a specified group and having a specified status.

§Parameters
  • group: The group name to filter by.
  • status: The status of the data items to include.
§Returns
  • A vector of references to matching DataItems.
Source

pub fn get_groups(&self) -> Vec<&str>

Returns a list of unique group names present in the stored data items.

§Returns
  • A vector of string slices representing distinct group names.

Trait Implementations§

Source§

impl Default for NVDM

Source§

fn default() -> Self

Creates a new NVDM instance with default configuration.

The peb_size is set to the default port-specific PEB size, and the items vector is initialized empty.

§Returns
  • An NVDM instance with default parameters.
Source§

impl FromStream for NVDM

Source§

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

Reads the NVDM data from a binary stream, parsing all physical erase blocks (PEBs) and extracting valid data items.

Iterates through each PEB, checking if it is active, then reads data items within, adding valid items to the internal collection.

§Parameters
  • reader: A mutable reference to a reader implementing Read and Seek.
§Returns
  • Ok(()) if all data was successfully read.
  • Err(Error) if an I/O or parsing error occurs.

Auto Trait Implementations§

§

impl Freeze for NVDM

§

impl RefUnwindSafe for NVDM

§

impl Send for NVDM

§

impl Sync for NVDM

§

impl Unpin for NVDM

§

impl UnwindSafe for NVDM

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.