multiversx_sc/storage/mappers/
mapper.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::{api::StorageMapperApi, storage::StorageKey, types::ManagedAddress};

pub trait StorageMapper<SA>: 'static
where
    SA: StorageMapperApi,
{
    /// Will be called automatically by the `#[storage_mapper]` annotation generated code.
    fn new(base_key: StorageKey<SA>) -> Self;
}

pub trait StorageMapperFromAddress<SA>: 'static
where
    SA: StorageMapperApi,
{
    /// Will be called automatically by the `#[storage_mapper_from_address]`
    /// annotation generated code.
    fn new_from_address(address: ManagedAddress<SA>, base_key: StorageKey<SA>) -> Self;
}

pub trait StorageClearable {
    /// Clears all the entries owned by the storage.
    fn clear(&mut self);
}