Struct secret_toolkit_storage::deque_store::DequeStoreMut
source · [−]pub struct DequeStoreMut<'a, T, S, Ser = Bincode2> where
T: Serialize + DeserializeOwned,
S: Storage,
Ser: Serde, { /* private fields */ }
Expand description
A type allowing both reads from and writes to the deque store at a given storage location.
Implementations
sourceimpl<'a, T, S> DequeStoreMut<'a, T, S, Bincode2> where
T: Serialize + DeserializeOwned,
S: Storage,
impl<'a, T, S> DequeStoreMut<'a, T, S, Bincode2> where
T: Serialize + DeserializeOwned,
S: Storage,
sourcepub fn attach_or_create(storage: &'a mut S) -> StdResult<Self>
pub fn attach_or_create(storage: &'a mut S) -> StdResult<Self>
Try to use the provided storage as an DequeStore. If it doesn’t seem to be one, then initialize it as one.
Returns Err if the contents of the storage can not be parsed.
sourceimpl<'a, T, S, Ser> DequeStoreMut<'a, T, S, Ser> where
T: Serialize + DeserializeOwned,
S: Storage,
Ser: Serde,
impl<'a, T, S, Ser> DequeStoreMut<'a, T, S, Ser> where
T: Serialize + DeserializeOwned,
S: Storage,
Ser: Serde,
sourcepub fn attach_or_create_with_serialization(
storage: &'a mut S,
_ser: Ser
) -> StdResult<Self>
pub fn attach_or_create_with_serialization(
storage: &'a mut S,
_ser: Ser
) -> StdResult<Self>
Try to use the provided storage as an DequeStore. If it doesn’t seem to be one, then initialize it as one. This method allows choosing the serialization format you want to use.
Returns Err if the contents of the storage can not be parsed.
sourcepub fn attach_with_serialization(
storage: &'a mut S,
_ser: Ser
) -> Option<StdResult<Self>>
pub fn attach_with_serialization(
storage: &'a mut S,
_ser: Ser
) -> Option<StdResult<Self>>
Try to use the provided storage as an DequeStore. This method allows choosing the serialization format you want to use.
Returns None if the provided storage doesn’t seem like an DequeStore. Returns Err if the contents of the storage can not be parsed.
pub fn len(&self) -> u32
pub fn is_empty(&self) -> bool
pub fn storage(&mut self) -> &mut S
pub fn readonly_storage(&self) -> &S
sourcepub fn iter(&self) -> Iter<'_, T, S, Ser>ⓘNotable traits for Iter<'a, T, S, Ser>impl<'a, T, S, Ser> Iterator for Iter<'a, T, S, Ser> where
T: Serialize + DeserializeOwned,
S: ReadonlyStorage,
Ser: Serde, type Item = StdResult<T>;
pub fn iter(&self) -> Iter<'_, T, S, Ser>ⓘNotable traits for Iter<'a, T, S, Ser>impl<'a, T, S, Ser> Iterator for Iter<'a, T, S, Ser> where
T: Serialize + DeserializeOwned,
S: ReadonlyStorage,
Ser: Serde, type Item = StdResult<T>;
T: Serialize + DeserializeOwned,
S: ReadonlyStorage,
Ser: Serde, type Item = StdResult<T>;
Return an iterator over the items in the collection
sourcepub fn get_at(&self, pos: u32) -> StdResult<T>
pub fn get_at(&self, pos: u32) -> StdResult<T>
Get the value stored at a given position.
Errors
Will return an error if pos is out of bounds or if an item is not found.
sourcepub fn set_at(&mut self, pos: u32, item: &T) -> StdResult<()>
pub fn set_at(&mut self, pos: u32, item: &T) -> StdResult<()>
Set the value of the item stored at a given position.
Errors
Will return an error if the position is out of bounds
sourcepub fn push_back(&mut self, item: &T) -> StdResult<()>
pub fn push_back(&mut self, item: &T) -> StdResult<()>
Append an item to the end of the collection.
This operation has a constant cost.
sourcepub fn push_front(&mut self, item: &T) -> StdResult<()>
pub fn push_front(&mut self, item: &T) -> StdResult<()>
Add an item to the begining of the collection.
This operation has a constant cost.
sourcepub fn pop_back(&mut self) -> StdResult<T>
pub fn pop_back(&mut self) -> StdResult<T>
Pop the last item off the collection
This operation has a constant cost.
sourcepub fn pop_front(&mut self) -> StdResult<T>
pub fn pop_front(&mut self) -> StdResult<T>
Pop the first item off the collection
This operation has a constant cost.
sourcepub fn remove(&mut self, pos: u32) -> StdResult<T>
pub fn remove(&mut self, pos: u32) -> StdResult<T>
Remove an element from the collection at the specified position.
Removing an element from the head (first) or tail (last) has a constant cost. The cost of removing from the middle will depend on the proximity to the head or tail. In that case, all the elements between the closest tip of the collection (head or tail) and the specified position will be shifted in storage.
Removing an element from the middle of the collection has the worst runtime and gas cost.
Trait Implementations
Auto Trait Implementations
impl<'a, T, S, Ser> RefUnwindSafe for DequeStoreMut<'a, T, S, Ser> where
S: RefUnwindSafe,
Ser: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, S, Ser = Bincode2> !Send for DequeStoreMut<'a, T, S, Ser>
impl<'a, T, S, Ser = Bincode2> !Sync for DequeStoreMut<'a, T, S, Ser>
impl<'a, T, S, Ser> Unpin for DequeStoreMut<'a, T, S, Ser>
impl<'a, T, S, Ser = Bincode2> !UnwindSafe for DequeStoreMut<'a, T, S, Ser>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more