pub struct StableVec<T: Storable, M: Memory = DefaultMemoryImpl> { /* private fields */ }Expand description
StableVec
A persistent vector over one exclusive, admitted allocation lease.
Elements require a finite codec bound. Length is cached by this owner after read-only admission and updated only after successful persistent mutations; observing length checks owner health without reading backing bytes.
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>
Admits the current vector image without modifying its bytes. Admission validates framing, codec bounds and the complete live extent, without decoding or scanning records.
§Errors
Returns Format for empty, foreign, unsupported or truncated framing,
or a length whose occupied extent cannot be represented or is absent.
§Panics
Panics for an unbounded or incompatible codec, a poisoned owner, or a backing IO failure.
Sourcepub fn get(&self, index: u64) -> Option<T>
pub fn get(&self, index: u64) -> Option<T>
Decodes one live record, or returns None when the index is absent.
§Panics
Panics for a poisoned owner, corrupt selected record, codec failure or backing IO failure. Unselected records are not decoded.
Sourcepub fn set(&self, index: u64, item: &T)
pub fn set(&self, index: u64, item: &T)
Replaces one existing record without changing the length.
§Panics
Panics for an absent index, a poisoned owner, codec failure, declared-bound violation or backing IO failure. Native mutation unwinding poisons the owner.
Sourcepub fn push(&self, item: &T)
pub fn push(&self, item: &T)
Appends one record and commits its new length after the record is written.
§Panics
Panics for a poisoned owner, codec failure, declared-bound violation, arithmetic overflow, growth refusal or backing IO failure. Native mutation unwinding poisons the owner.
Sourcepub fn pop(&self) -> Option<T>
pub fn pop(&self) -> Option<T>
Removes and returns the final record, or returns None when empty.
§Panics
Panics for a poisoned owner, corrupt selected record, codec failure or backing IO failure. Native mutation unwinding poisons the owner.
Sourcepub fn len(&self) -> u64
pub fn len(&self) -> u64
Returns the locally cached committed length after checking owner health.
§Panics
Panics if the owner has been poisoned.
Sourcepub fn iter(&self) -> impl DoubleEndedIterator<Item = T> + '_
pub fn iter(&self) -> impl DoubleEndedIterator<Item = T> + '_
Iterates within the length observed at creation, reading current values. Advancing, skipping or counting permanently truncates the remaining endpoint to the current length. Removed records are never read; replacements or re-appends inside an unconsumed endpoint may be observed. Appends beyond the original endpoint are excluded, and exhaustion is permanent. Skipping and counting do not decode unselected records.
§Panics
Panics for a poisoned owner. Selecting a record may panic for corrupt
data, codec failure or backing IO failure. Counting panics if the remaining
length cannot fit in usize.