pub struct StableVec<T: Storable, M: Memory = DefaultMemoryImpl> { /* private fields */ }Expand description
StableVec
ICSS-baseline fixed-stride vector in one governed allocation. There are no custom checksums, cached length, read windows or mutation epochs. Malformed stored values trap; IC execution rollback supplies atomicity.
Implementations§
Source§impl<T: Storable, M: Memory> StableVec<T, M>
impl<T: Storable, M: Memory> StableVec<T, 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>
Sourcepub fn load(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>
pub fn load(memory: RuntimeMemory<M>) -> Result<Self, CollectionError>
Sourcepub fn get(&self, index: u64) -> Option<T>
pub fn get(&self, index: u64) -> Option<T>
Read one indexed record; malformed stored bytes trap.
Sourcepub fn set(&self, index: u64, item: &T)
pub fn set(&self, index: u64, item: &T)
Replace one record; invalid codecs, bounds or writes trap.
Sourcepub fn iter(&self) -> impl DoubleEndedIterator<Item = T> + '_
pub fn iter(&self) -> impl DoubleEndedIterator<Item = T> + '_
Bidirectional iteration with one reusable buffer. Direct skips and last()
decode only the selected record; they do not validate discarded records.
Auto Trait Implementations§
impl<T, M = Rc<RefCell<Vec<u8>>>> !RefUnwindSafe for StableVec<T, M>
impl<T, M = Rc<RefCell<Vec<u8>>>> !Send for StableVec<T, M>
impl<T, M = Rc<RefCell<Vec<u8>>>> !Sync for StableVec<T, M>
impl<T, M = Rc<RefCell<Vec<u8>>>> !UnwindSafe for StableVec<T, M>
impl<T, M> Forget for StableVec<T, M>
impl<T, M> Freeze for StableVec<T, M>where
Vec<Codec<T>, RuntimeMemory<M>>: Freeze,
impl<T, M> Unpin for StableVec<T, M>where
Vec<Codec<T>, RuntimeMemory<M>>: Unpin,
impl<T, M> UnsafeUnpin for StableVec<T, M>where
Vec<Codec<T>, RuntimeMemory<M>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more