Expand description
RAM-buffered wrapper for QueueStorage.
NOR flash writes are slow and erases are very slow. If a producer emits data faster than the
flash interface can commit it, BufferedQueue accepts items into a fixed-size RAM ring
buffer via the synchronous enqueue call (no flash I/O) and
asynchronously drains them to flash via drain_one or
drain_all.
§Overflow policy
When the RAM ring is full, enqueue behaviour is controlled by
OverflowPolicy: either return Err(()) or silently evict the oldest buffered item.
§Ordering
FIFO ordering is preserved: flash items are always older than RAM items.
pop and peek read from flash first,
falling back to the oldest RAM item if flash is empty.
§Power-fail note
Items that are in the RAM ring and have not yet been drained to flash will be lost on power loss. Items that have been drained follow the power-fail safety guarantees of sequential-storage.
§Embassy / ISR-safe use
Enable the shared-ram-ring feature for [SharedRamRing], which wraps the ring in a
critical-section mutex so it can be enqueued to from an interrupt handler, and signals
a drain task the moment data arrives.
Structs§
- Buffered
Queue - A write-buffered queue that accepts items into a RAM ring and drains them to NOR flash.
Enums§
- Overflow
Policy - Controls what happens when
enqueueis called on a full RAM ring.