Skip to main content

Module containers

Module containers 

Source
Expand description

Fixed-capacity containers re-exported from heapless.

These containers compile in both heap and zeroheap modes because their capacity is a const generic and their storage is owned in the type — no global allocator is ever consulted. Use them for general-purpose collections (resizable vectors, fixed strings, hashmaps, deques) that complement the RTOS-aware primitives (ove::Queue, ove::Stream).

use ove::containers::{Vec, String};
use ove::containers::ContainerExt;

let mut buf: Vec<u8, 64> = Vec::new();
let _ = buf.ove_push(0xAB);   // Result<(), ove::Error>

let mut name: String<32> = String::new();
let _ = name.push_str("hello");

§Choosing between ove::heap::Vec and ove::containers::Vec

  • crate::heap::Vec (re-exported from alloc::vec::Vec) is a growable vector backed by the global allocator. Available only when the alloc (or std) feature is enabled and a #[global_allocator] is registered. Cannot be used in zeroheap mode.

  • Vec<T, N> from this module is fixed-capacity; capacity is a const generic and storage lives inline in the type. Always available, in both heap and zeroheap modes. Fallible: push returns Result<(), T>; the ContainerExt::ove_push adapter converts that into crate::Error::NoMemory for consistency with the rest of the binding’s error type.

§What is intentionally not re-exported

  • heapless::spsc::Queue and heapless::mpmc::Q* overlap semantically with crate::Queue (the kernel-aware FIFO). Apps that explicitly want a lock-free SPSC ring should reach into heapless::spsc directly — the extra import documents the intent.

Modules§

binary_heap
A priority queue implemented with a binary heap.
sorted_linked_list
A fixed sorted priority linked list, similar to BinaryHeap but with different properties on push, pop, etc.

Structs§

IndexMap
Fixed capacity IndexMap
IndexSet
Fixed capacity IndexSet.

Traits§

ContainerExt
Adapter trait that maps a heapless container’s capacity-overflow return into an crate::Error::NoMemory. Use the ove_* methods when you want the result to flow through the same ? chain as other ove::Result calls.

Functions§

ove_push_str
Append a string slice to a fixed-capacity String, returning crate::Error::NoMemory when the buffer is full.

Type Aliases§

Deque
A fixed capacity double-ended queue.
HistoryBuf
A “history buffer”, similar to a write-only ring buffer of fixed length.
LinearMap
A fixed capacity map/dictionary that performs lookups via linear search.
String
A fixed capacity String.
Vec
A fixed capacity Vec.