A crate for storing data in flash with minimal erase cycles.
There are two datastructures:
Each live in their own module. See the module documentation for more info and examples.
Make sure not to mix the datastructures in flash! You can't fetch a key-value item from a flash region where you pushed to the queue.
The idea behind this crate it to save on flash erase cycles by storing every item in an append-only way. Only the most recent value of a key-value item is 'active'.
This is more efficient because we don't have to erase a page every time we want to update a value.
Every item has to fit in a page. Once an item is too big to fit on the current page will be closed and the item will be stored on the next page.
Once all pages have been closed, the next page will be erased to open it up again. There is the possibility that the erased page contains the only copy of a key, so the crate checks if that happens and if it does add that key-value item back in. In principle you will never lose any data.
Pages work in the same way as for the map.
All data is stored as u16 BE length + data. Push appends the data at the next spot. If there's no more room, a push can erase the oldest page to make space, but only does so when configured.
Peeking and popping look at the oldest data it can find. When popping, the data is also erased by writing all 0's over it.
push
, peek
and pop
which requires multiwrite flash