Struct secret_toolkit_storage::append_store::AppendStore
source · pub struct AppendStore<'a, T, Ser = Bincode2>{ /* private fields */ }
Implementations§
source§impl<'a, T: Serialize + DeserializeOwned, Ser: Serde> AppendStore<'a, T, Ser>
impl<'a, T: Serialize + DeserializeOwned, Ser: Serde> AppendStore<'a, T, Ser>
pub const fn new_with_page_size(namespace: &'a [u8], page_size: u32) -> Self
sourcepub fn add_suffix(&self, suffix: &[u8]) -> Self
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>
impl<'a, T: Serialize + DeserializeOwned, Ser: Serde> AppendStore<'a, T, Ser>
sourcepub fn get_len(&self, storage: &dyn Storage) -> StdResult<u32>
pub fn get_len(&self, storage: &dyn Storage) -> StdResult<u32>
gets the length from storage, and otherwise sets it to 0
sourcepub fn is_empty(&self, storage: &dyn Storage) -> StdResult<bool>
pub fn is_empty(&self, storage: &dyn Storage) -> StdResult<bool>
checks if the collection has any elements
sourcepub fn get_at(&self, storage: &dyn Storage, pos: u32) -> StdResult<T>
pub fn get_at(&self, storage: &dyn Storage, pos: u32) -> StdResult<T>
gets the element at pos if within bounds
sourcepub fn set_at(
&self,
storage: &mut dyn Storage,
pos: u32,
item: &T
) -> StdResult<()>
pub fn set_at( &self, storage: &mut dyn Storage, pos: u32, item: &T ) -> StdResult<()>
Replaces data at a position within bounds
sourcepub fn push(&self, storage: &mut dyn Storage, item: &T) -> StdResult<()>
pub fn push(&self, storage: &mut dyn Storage, item: &T) -> StdResult<()>
Pushes an item to AppendStorage
sourcepub fn remove(&self, storage: &mut dyn Storage, pos: u32) -> StdResult<T>
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.
sourcepub fn iter(
&self,
storage: &'a dyn Storage
) -> StdResult<AppendStoreIter<'_, T, Ser>>
pub fn iter( &self, storage: &'a dyn Storage ) -> StdResult<AppendStoreIter<'_, T, Ser>>
Returns a readonly iterator