pub struct AppendStore<'a, T, Ser = Bincode2>
where T: Serialize + DeserializeOwned, Ser: Serde,
{ /* private fields */ }

Implementations§

source§

impl<'a, T: Serialize + DeserializeOwned, Ser: Serde> AppendStore<'a, T, Ser>

source

pub const fn new(namespace: &'a [u8]) -> Self

constructor

source

pub const fn new_with_page_size(namespace: &'a [u8], page_size: u32) -> Self

source

pub fn add_suffix(&self, suffix: &[u8]) -> Self

This is used to produce a new AppendListStorage. This can be used when you want to associate an AppendListStorage to each user and you still get to define the AppendListStorage as a static constant

source§

impl<'a, T: Serialize + DeserializeOwned, Ser: Serde> AppendStore<'a, T, Ser>

source

pub fn get_len(&self, storage: &dyn Storage) -> StdResult<u32>

gets the length from storage, and otherwise sets it to 0

source

pub fn is_empty(&self, storage: &dyn Storage) -> StdResult<bool>

checks if the collection has any elements

source

pub fn get_at(&self, storage: &dyn Storage, pos: u32) -> StdResult<T>

gets the element at pos if within bounds

source

pub fn clear(&self, storage: &mut dyn Storage)

Clear the collection

source

pub fn set_at( &self, storage: &mut dyn Storage, pos: u32, item: &T ) -> StdResult<()>

Replaces data at a position within bounds

source

pub fn push(&self, storage: &mut dyn Storage, item: &T) -> StdResult<()>

Pushes an item to AppendStorage

source

pub fn pop(&self, storage: &mut dyn Storage) -> StdResult<T>

Pops an item from AppendStore

source

pub fn remove(&self, storage: &mut dyn Storage, pos: u32) -> StdResult<T>

Remove an element from the collection at the specified position.

Removing the last element has a constant cost. The cost of removing from the middle/start will depend on the proximity to tail of the list. All elements above the specified position will be shifted in storage.

Removing an element from the start (head) of the collection has the worst runtime and gas cost.

source

pub fn iter( &self, storage: &'a dyn Storage ) -> StdResult<AppendStoreIter<'_, T, Ser>>

Returns a readonly iterator

source

pub fn paging( &self, storage: &dyn Storage, start_page: u32, size: u32 ) -> StdResult<Vec<T>>

does paging with the given parameters

Auto Trait Implementations§

§

impl<'a, T, Ser> RefUnwindSafe for AppendStore<'a, T, Ser>

§

impl<'a, T, Ser> Send for AppendStore<'a, T, Ser>
where Ser: Send, T: Send,

§

impl<'a, T, Ser> Sync for AppendStore<'a, T, Ser>
where Ser: Sync, T: Sync,

§

impl<'a, T, Ser> Unpin for AppendStore<'a, T, Ser>
where Ser: Unpin, T: Unpin,

§

impl<'a, T, Ser> UnwindSafe for AppendStore<'a, T, Ser>
where Ser: UnwindSafe, T: UnwindSafe,

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.