Skip to main content

StableVec

Struct StableVec 

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

Source

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

Creates an empty vector in an empty allocation.

§Errors

Returns NotEmpty for a nonempty allocation or Growth if the initial header reservation is refused.

§Panics

Panics for an unbounded codec, a poisoned owner, or a backing IO failure.

Source

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

Explicitly replaces the allocation’s image with an empty vector. Unreachable previous payload bytes need not be erased.

§Errors

Returns Growth if the initial header reservation is refused.

§Panics

Panics for an unbounded codec, a poisoned owner, or a backing IO failure.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn len(&self) -> u64

Returns the locally cached committed length after checking owner health.

§Panics

Panics if the owner has been poisoned.

Source

pub fn is_empty(&self) -> bool

Returns whether the committed length is zero.

§Panics

Panics if the owner has been poisoned.

Source

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.

Auto Trait Implementations§

§

impl<T, M = Rc<RefCell<Vec<u8>>>> !Freeze for StableVec<T, M>

§

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> Move for StableVec<T, M>

§

impl<T, M> Unpin for StableVec<T, M>

§

impl<T, M> UnsafeUnpin for StableVec<T, M>

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.