Struct multiversx_sc::storage::mappers::UnorderedSetMapper
source · pub struct UnorderedSetMapper<SA, T>where
SA: StorageMapperApi,
T: TopEncode + TopDecode + NestedEncode + NestedDecode + 'static,{ /* private fields */ }
Implementations§
source§impl<SA, T> UnorderedSetMapper<SA, T>where
SA: StorageMapperApi,
T: TopEncode + TopDecode + NestedEncode + NestedDecode,
impl<SA, T> UnorderedSetMapper<SA, T>where SA: StorageMapperApi, T: TopEncode + TopDecode + NestedEncode + NestedDecode,
pub fn get_index(&self, value: &T) -> usize
sourcepub fn get_index_at_address(
&self,
address: &ManagedAddress<SA>,
value: &T
) -> usize
pub fn get_index_at_address( &self, address: &ManagedAddress<SA>, value: &T ) -> usize
Gets the item’s index at the given address’ mapper.
Returns 0
if the item is not in the list.
sourcepub fn get_by_index(&self, index: usize) -> T
pub fn get_by_index(&self, index: usize) -> T
Get item at index from storage. Index must be valid (1 <= index <= count).
sourcepub fn get_by_index_at_address(
&self,
address: &ManagedAddress<SA>,
index: usize
) -> T
pub fn get_by_index_at_address( &self, address: &ManagedAddress<SA>, index: usize ) -> T
Gets the item by index from the given address. Index must be valid (1 <= index <= count).
sourcepub fn is_empty_at_address(&self, address: &ManagedAddress<SA>) -> bool
pub fn is_empty_at_address(&self, address: &ManagedAddress<SA>) -> bool
Returns true
if the address’ mapper contains no elements.
sourcepub fn len_at_address(&self, address: &ManagedAddress<SA>) -> usize
pub fn len_at_address(&self, address: &ManagedAddress<SA>) -> usize
Returns the number of elements contained in the given address’ mapper.
sourcepub fn contains_at_address(
&self,
address: &ManagedAddress<SA>,
value: &T
) -> bool
pub fn contains_at_address( &self, address: &ManagedAddress<SA>, value: &T ) -> bool
Returns true
if the mapper at the given address contains the value.
sourcepub fn insert(&mut self, value: T) -> bool
pub fn insert(&mut self, value: T) -> bool
Adds a value to the set.
If the set did not have this value present, true
is returned.
If the set did have this value present, false
is returned.
sourcepub fn swap_remove(&mut self, value: &T) -> bool
pub fn swap_remove(&mut self, value: &T) -> bool
Removes a value from the set. Returns whether the value was present in the set.
sourcepub fn swap_indexes(&mut self, index1: usize, index2: usize) -> bool
pub fn swap_indexes(&mut self, index1: usize, index2: usize) -> bool
Exchanges the indexes of two values. Returns whether the operation was successful.
Trait Implementations§
source§impl<SA, T> Extend<T> for UnorderedSetMapper<SA, T>where
SA: StorageMapperApi,
T: TopEncode + TopDecode + NestedEncode + NestedDecode + 'static,
impl<SA, T> Extend<T> for UnorderedSetMapper<SA, T>where SA: StorageMapperApi, T: TopEncode + TopDecode + NestedEncode + NestedDecode + 'static,
source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = T>,
fn extend<I>(&mut self, iter: I)where I: IntoIterator<Item = T>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<'a, SA, T> IntoIterator for &'a UnorderedSetMapper<SA, T>where
SA: StorageMapperApi,
T: TopEncode + TopDecode + NestedEncode + NestedDecode + 'static,
impl<'a, SA, T> IntoIterator for &'a UnorderedSetMapper<SA, T>where SA: StorageMapperApi, T: TopEncode + TopDecode + NestedEncode + NestedDecode + 'static,
source§impl<SA, T> StorageClearable for UnorderedSetMapper<SA, T>where
SA: StorageMapperApi,
T: TopEncode + TopDecode + NestedEncode + NestedDecode,
impl<SA, T> StorageClearable for UnorderedSetMapper<SA, T>where SA: StorageMapperApi, T: TopEncode + TopDecode + NestedEncode + NestedDecode,
source§impl<SA, T> StorageMapper<SA> for UnorderedSetMapper<SA, T>where
SA: StorageMapperApi,
T: TopEncode + TopDecode + NestedEncode + NestedDecode,
impl<SA, T> StorageMapper<SA> for UnorderedSetMapper<SA, T>where SA: StorageMapperApi, T: TopEncode + TopDecode + NestedEncode + NestedDecode,
source§fn new(base_key: StorageKey<SA>) -> Self
fn new(base_key: StorageKey<SA>) -> Self
#[storage_mapper]
annotation generated code.source§impl<SA, T> TopEncodeMulti for UnorderedSetMapper<SA, T>where
SA: StorageMapperApi,
T: TopEncode + TopDecode + NestedEncode + NestedDecode + 'static,
impl<SA, T> TopEncodeMulti for UnorderedSetMapper<SA, T>where SA: StorageMapperApi, T: TopEncode + TopDecode + NestedEncode + NestedDecode + 'static,
Behaves like a MultiResultVec when an endpoint result.
source§fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
fn multi_encode_or_handle_err<O, H>( &self, output: &mut O, h: H ) -> Result<(), H::HandledErr>where O: TopEncodeMultiOutput, H: EncodeErrorHandler,
top_encode
that can handle errors as soon as they occur.
For instance in can exit immediately and make sure that if it returns, it is a success.
By not deferring error handling, this can lead to somewhat smaller bytecode.source§fn multi_encode<O>(&self, output: &mut O) -> Result<(), EncodeError>where
O: TopEncodeMultiOutput,
fn multi_encode<O>(&self, output: &mut O) -> Result<(), EncodeError>where O: TopEncodeMultiOutput,
source§impl<SA, T> TypeAbi for UnorderedSetMapper<SA, T>where
SA: StorageMapperApi,
T: TopEncode + TopDecode + NestedEncode + NestedDecode + TypeAbi,
impl<SA, T> TypeAbi for UnorderedSetMapper<SA, T>where SA: StorageMapperApi, T: TopEncode + TopDecode + NestedEncode + NestedDecode + TypeAbi,
Behaves like a MultiResultVec when an endpoint result.