Trait fuel_storage::Mappable
source · pub trait Mappable {
type Key: ?Sized + ToOwned;
type OwnedKey: From<<Self::Key as ToOwned>::Owned> + Clone;
type Value: ?Sized + ToOwned;
type OwnedValue: From<<Self::Value as ToOwned>::Owned> + Clone;
}
Expand description
Mappable type with Key
and Value
.
§Example
use fuel_storage::Mappable;
pub struct Contract;
impl Mappable for Contract {
/// The `[u8; 32]` is a primitive type, so we can't optimize it more.
type Key = Self::OwnedKey;
type OwnedKey = [u8; 32];
/// It is optimized to use slice instead of vector.
type Value = [u8];
type OwnedValue = Vec<u8>;
}
Required Associated Types§
sourcetype Key: ?Sized + ToOwned
type Key: ?Sized + ToOwned
The key type is used during interaction with the storage. In most cases, it is the
same as Self::OwnedKey
.
sourcetype OwnedKey: From<<Self::Key as ToOwned>::Owned> + Clone
type OwnedKey: From<<Self::Key as ToOwned>::Owned> + Clone
The owned type of the Key
retrieving from the storage.
Object Safety§
This trait is not object safe.