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);
}Implementations§
Source§impl<K: Key, S: NorFlash, C: KeyCacheImpl<K>> MapItemIter<'_, K, S, C>
impl<K: Key, S: NorFlash, C: KeyCacheImpl<K>> MapItemIter<'_, K, S, C>
Auto Trait Implementations§
impl<'s, K, S, C> Freeze for MapItemIter<'s, K, S, C>
impl<'s, K, S, C> RefUnwindSafe for MapItemIter<'s, K, S, C>
impl<'s, K, S, C> Send for MapItemIter<'s, K, S, C>
impl<'s, K, S, C> Sync for MapItemIter<'s, K, S, C>
impl<'s, K, S, C> Unpin for MapItemIter<'s, K, S, C>where
K: Unpin,
impl<'s, K, S, C> !UnwindSafe for MapItemIter<'s, K, S, C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more