Module sequential_storage::map

source ·
Expand description

A module for storing key-value pairs in flash with minimal erase cycles.

Basic API:

enum MyCustomType {
    X,
    Y,
    // ...
}

impl StorageItem for MyCustomType {
    // ...
}

let mut flash = SomeFlashChip::new();
let flash_range = 0x1000..0x2000; // These are the flash addresses in which the crate will operate

assert_eq!(
    fetch_item::<MyCustomType, SomeFlashChip>(
        &mut flash,
        flash_range.clone(),
        0
    ).unwrap(),
    None
);

store_item::<MyCustomType, SomeFlashChip, SomeFlashChip::ERASE_SIZE>(
    &mut flash,
    flash_range.clone(),
    MyCustomType::X
).unwrap();

assert_eq!(
    fetch_item::<MyCustomType, SomeFlashChip>(
        &mut flash,
        flash_range.clone(),
        0
    ).unwrap(),
    Some(MyCustomType::X)
);

Enums

Constants

Traits

  • A way of serializing and deserializing items in the storage.
  • A trait that the storage item error needs to implement

Functions

  • Get a storage item from the flash. Only the last stored item of the given key is returned.
  • Store an item into flash memory. It will overwrite the last value that has the same key.