pub struct StableBTreeMap<K: Storable + Ord + Clone, V: Storable, M: Memory = DefaultMemoryImpl> { /* private fields */ }Expand description
StableBTreeMap
ICSS-baseline ordered map owning one governed allocation. Stored codec and engine failures trap. Native callers must discard the runtime after a mutation panic.
Implementations§
Source§impl<K: Storable + Ord + Clone, V: Storable, M: Memory> StableBTreeMap<K, V, M>
impl<K: Storable + Ord + Clone, V: Storable, M: Memory> StableBTreeMap<K, V, M>
Sourcepub fn create(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>
pub fn create(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>
Sourcepub fn reset(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>
pub fn reset(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>
Explicitly replace this allocation’s collection image.
§Errors
Refuses initial growth before creating the map.
Sourcepub fn load(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>
pub fn load(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>
Load the current BTR version without initialization or migration.
§Errors
Refuses empty or foreign framing.
Sourcepub fn clear(&mut self) -> Result<(), CollectionError>
pub fn clear(&mut self) -> Result<(), CollectionError>
Clear entries and reuse the map’s existing backing capacity.
§Errors
Engine failures trap instead of returning an ordinary error.
Sourcepub const fn set_node_cache_budget(&mut self, _bytes: usize)
pub const fn set_node_cache_budget(&mut self, _bytes: usize)
Bound routing-cache memory. The baseline engine caches no routing nodes, so every supplied ceiling is satisfied with zero cached bytes.
Sourcepub fn reserve_pages(self, minimum: u64) -> (Self, Result<(), RuntimeGrowError>)
pub fn reserve_pages(self, minimum: u64) -> (Self, Result<(), RuntimeGrowError>)
Reserve backing pages without promising entry capacity.
Sourcepub fn allocated_pages(self) -> (Self, u64)
pub fn allocated_pages(self) -> (Self, u64)
Observe allocated pages while retaining exclusive custody.
Sourcepub fn insert(&mut self, key: K, value: V) -> Result<Option<V>, CollectionError>
pub fn insert(&mut self, key: K, value: V) -> Result<Option<V>, CollectionError>
Insert or replace. Invalid codecs and allocation failures trap.
§Errors
Engine failures trap instead of returning an ordinary error.
Sourcepub fn get(&self, key: &K) -> Result<Option<V>, CollectionError>
pub fn get(&self, key: &K) -> Result<Option<V>, CollectionError>
Read a matching value; malformed stored values trap.
§Errors
Engine failures trap instead of returning an ordinary error.
Sourcepub fn contains_key(&self, key: &K) -> Result<bool, CollectionError>
pub fn contains_key(&self, key: &K) -> Result<bool, CollectionError>
Test key membership without decoding values.
§Errors
Engine failures trap instead of returning an ordinary error.
Sourcepub fn remove(&mut self, key: &K) -> Result<Option<V>, CollectionError>
pub fn remove(&mut self, key: &K) -> Result<Option<V>, CollectionError>
Remove a matching value; codec and engine failures trap.
§Errors
Engine failures trap instead of returning an ordinary error.
Sourcepub fn first_key_value(&self) -> Result<Option<(K, V)>, CollectionError>
pub fn first_key_value(&self) -> Result<Option<(K, V)>, CollectionError>
Sourcepub fn last_key_value(&self) -> Result<Option<(K, V)>, CollectionError>
pub fn last_key_value(&self) -> Result<Option<(K, V)>, CollectionError>
Sourcepub fn range(&self, bounds: impl RangeBounds<K>) -> MapIter<'_, K, V, M> ⓘ
pub fn range(&self, bounds: impl RangeBounds<K>) -> MapIter<'_, K, V, M> ⓘ
Iterate a bounded key range.
Sourcepub fn keys(
&self,
) -> impl DoubleEndedIterator<Item = Result<K, CollectionError>> + '_
pub fn keys( &self, ) -> impl DoubleEndedIterator<Item = Result<K, CollectionError>> + '_
Iterate keys without reading value payloads.
Sourcepub fn keys_range(
&self,
bounds: impl RangeBounds<K>,
) -> impl DoubleEndedIterator<Item = Result<K, CollectionError>> + '_
pub fn keys_range( &self, bounds: impl RangeBounds<K>, ) -> impl DoubleEndedIterator<Item = Result<K, CollectionError>> + '_
Iterate bounded keys without reading value payloads.
Sourcepub fn values(
&self,
) -> impl DoubleEndedIterator<Item = Result<V, CollectionError>> + '_
pub fn values( &self, ) -> impl DoubleEndedIterator<Item = Result<V, CollectionError>> + '_
Iterate decoded values.