Skip to main content

StableBTreeMap

Struct StableBTreeMap 

Source
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>

Source

pub fn create(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>

Create only in empty admitted memory.

§Errors

Refuses nonempty memory or initial growth refusal.

Source

pub fn reset(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>

Explicitly replace this allocation’s collection image.

§Errors

Refuses initial growth before creating the map.

Source

pub fn load(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>

Load the current BTR version without initialization or migration.

§Errors

Refuses empty or foreign framing.

Source

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.

Source

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.

Source

pub fn reserve_pages(self, minimum: u64) -> (Self, Result<(), RuntimeGrowError>)

Reserve backing pages without promising entry capacity.

Source

pub fn allocated_pages(self) -> (Self, u64)

Observe allocated pages while retaining exclusive custody.

Source

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.

Source

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.

Source

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.

Source

pub const fn is_empty(&self) -> bool

Whether no entries are committed.

Source

pub const fn len(&self) -> u64

Number of entries.

Source

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.

Source

pub fn first_key_value(&self) -> Result<Option<(K, V)>, CollectionError>

First ordered key/value pair.

§Errors

Engine failures trap instead of returning an ordinary error.

Source

pub fn last_key_value(&self) -> Result<Option<(K, V)>, CollectionError>

Last ordered key/value pair.

§Errors

Engine failures trap instead of returning an ordinary error.

Source

pub fn iter(&self) -> MapIter<'_, K, V, M> ⓘ

Iterate in key order.

Source

pub fn range(&self, bounds: impl RangeBounds<K>) -> MapIter<'_, K, V, M> ⓘ

Iterate a bounded key range.

Source

pub fn keys( &self, ) -> impl DoubleEndedIterator<Item = Result<K, CollectionError>> + '_

Iterate keys without reading value payloads.

Source

pub fn keys_range( &self, bounds: impl RangeBounds<K>, ) -> impl DoubleEndedIterator<Item = Result<K, CollectionError>> + '_

Iterate bounded keys without reading value payloads.

Source

pub fn values( &self, ) -> impl DoubleEndedIterator<Item = Result<V, CollectionError>> + '_

Iterate decoded values.

Trait Implementations§

Source§

impl<'a, K: Storable + Ord + Clone, V: Storable, M: Memory> IntoIterator for &'a StableBTreeMap<K, V, M>

Source§

type Item = <MapIter<'a, K, V, M> as Iterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = MapIter<'a, K, V, M>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<K, V, M = Rc<RefCell<Vec<u8>>>> !RefUnwindSafe for StableBTreeMap<K, V, M>

§

impl<K, V, M = Rc<RefCell<Vec<u8>>>> !Send for StableBTreeMap<K, V, M>

§

impl<K, V, M = Rc<RefCell<Vec<u8>>>> !Sync for StableBTreeMap<K, V, M>

§

impl<K, V, M = Rc<RefCell<Vec<u8>>>> !UnwindSafe for StableBTreeMap<K, V, M>

§

impl<K, V, M> Forget for StableBTreeMap<K, V, M>

§

impl<K, V, M> Freeze for StableBTreeMap<K, V, M>
where BTreeMap<Codec<K>, Codec<V>, Backing<RuntimeMemory<M>>>: Freeze,

§

impl<K, V, M> Unpin for StableBTreeMap<K, V, M>
where BTreeMap<Codec<K>, Codec<V>, Backing<RuntimeMemory<M>>>: Unpin,

§

impl<K, V, M> UnsafeUnpin for StableBTreeMap<K, V, M>
where BTreeMap<Codec<K>, Codec<V>, Backing<RuntimeMemory<M>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.