StorageStack

Trait StorageStack 

Source
pub trait StorageStack {
    // Required methods
    fn new_with(&self, offset: Offset) -> Self;
    fn offset(&self) -> Offset;
    fn push<T>(&mut self, t: T) -> Result<(), Error>
       where T: ArgumentEncoder;
    fn pop<T>(&mut self) -> Result<T, Error>
       where T: for<'de> ArgumentDecoder<'de>;
    fn seek_prev(&mut self) -> Result<(), Error>;
}
Expand description

Stack interface for stable memory that supports push and pop of arbitrary values that implement the Candid interface.

Required Methods§

Source

fn new_with(&self, offset: Offset) -> Self

Return a new StorageStack object with the given offset.

Source

fn offset(&self) -> Offset

Return the current read/write offset.

Source

fn push<T>(&mut self, t: T) -> Result<(), Error>
where T: ArgumentEncoder,

Push a value to the end of the stack.

Source

fn pop<T>(&mut self) -> Result<T, Error>
where T: for<'de> ArgumentDecoder<'de>,

Pop a value from the end of the stack. In case of OutOfBounds error, offset is not changed. In case of Candid decoding error, offset may be changed.

Source

fn seek_prev(&mut self) -> Result<(), Error>

Seek to the start of previous value by changing the offset. This is similar to pop but without reading the actual value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§