pub struct MapItemIter<'s, K: Key, S: NorFlash, C: KeyCacheImpl<K>> { /* private fields */ }Expand description
Iterator which iterates all non-erased & non-corrupted items in the map.
The iterator will return the (Key, Value) tuple when calling next().
If the iterator ends, it will return Ok(None).
The following is a simple example of how to use the iterator:
let mut flash = init_flash();
let mut storage = MapStorage::<u8, _, _>::new(flash, const { MapConfig::new(0x1000..0x3000) }, NoCache::new());
let mut data_buffer = [0; 128];
// Create the iterator of map items
let mut iterator = storage.fetch_all_items(
&mut data_buffer
)
.await
.unwrap();
let mut all_items = HashMap::new();
// Iterate through all items, suppose the Key and Value types are u8, u32
while let Some((key, value)) = iterator
.next::<u32>(&mut data_buffer)
.await
.unwrap()
{
// Do something with the item.
// Please note that for the same key there might be multiple items returned,
// the last one is the current active one.
all_items.insert(key, value);
}