pub struct StableVec<T: Storable, M: Memory = DefaultMemoryImpl> { /* private fields */ }Expand description
Governed upstream Vec; initialization and failures follow upstream contracts.
Implementations§
Source§impl<T: Storable, M: Memory> StableVec<T, M>
impl<T: Storable, M: Memory> StableVec<T, M>
Sourcepub fn create(memory: RuntimeMemory<M>) -> Self
pub fn create(memory: RuntimeMemory<M>) -> Self
Create a collection only in zero-page memory.
§Panics
Refuses nonempty memory before writing. Growth and codec failures retain upstream behavior.
Sourcepub fn reset(memory: RuntimeMemory<M>) -> Self
pub fn reset(memory: RuntimeMemory<M>) -> Self
Deliberately replace any contents in this admitted allocation.
§Panics
Growth and codec failures retain upstream behavior.
Sourcepub fn load(memory: RuntimeMemory<M>) -> Self
pub fn load(memory: RuntimeMemory<M>) -> Self
Load retained collection state without initializing a replacement.
§Panics
Refuses empty or foreign memory and incompatible layouts/bounds without writing. Record decoding and backing failures retain upstream behavior.
Sourcepub fn get(&self, index: u64) -> Option<T>
pub fn get(&self, index: u64) -> Option<T>
Delegates to upstream Vec::get with the governed allocation.
Sourcepub fn set(&self, index: u64, item: &T)
pub fn set(&self, index: u64, item: &T)
Delegates to upstream Vec::set with the governed allocation.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Delegates to upstream Vec::is_empty with the governed allocation.
Sourcepub fn iter(&self) -> impl DoubleEndedIterator<Item = T> + '_
pub fn iter(&self) -> impl DoubleEndedIterator<Item = T> + '_
Delegates to upstream Vec::iter with the governed allocation.