pub trait Mappable {
    type Key: ToOwned + ?Sized;
    type OwnedKey: From<<Self::Key as ToOwned>::Owned> + Clone;
    type Value: ToOwned + ?Sized;
    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§

type Key: ToOwned + ?Sized

The key type is used during interaction with the storage. In most cases, it is the same as Self::OwnedKey.

type OwnedKey: From<<Self::Key as ToOwned>::Owned> + Clone

The owned type of the Key retrieving from the storage.

type Value: ToOwned + ?Sized

The value type is used while setting the value to the storage. In most cases, it is the same as Self::OwnedValue, but it is without restriction and can be used for performance optimizations.

type OwnedValue: From<<Self::Value as ToOwned>::Owned> + Clone

The owned type of the Value retrieving from the storage.

Implementations on Foreign Types§

§

impl Mappable for NodesTable

§

type Key = <NodesTable as Mappable>::OwnedKey

§

type OwnedKey = [u8; 32]

§

type Value = <NodesTable as Mappable>::OwnedValue

§

type OwnedValue = (u32, u8, [u8; 32], [u8; 32])

§

impl Mappable for NodesTable

§

type Key = <NodesTable as Mappable>::OwnedKey

§

type OwnedKey = u64

§

type Value = <NodesTable as Mappable>::OwnedValue

§

type OwnedValue = (u64, [u8; 32])

Implementors§

source§

impl Mappable for Coins

source§

impl Mappable for ContractsAssets

source§

impl Mappable for ContractsInfo

§

type Key = <ContractsInfo as Mappable>::OwnedKey

§

type OwnedKey = ContractId

§

type Value = (Salt, Bytes32)

§

type OwnedValue = <ContractsInfo as Mappable>::Value

source§

impl Mappable for ContractsLatestUtxo

source§

impl Mappable for ContractsRawCode

§

type Key = <ContractsRawCode as Mappable>::OwnedKey

§

type OwnedKey = ContractId

§

type Value = [u8]

§

type OwnedValue = Contract

source§

impl Mappable for ContractsState

source§

impl Mappable for FuelBlocks

source§

impl Mappable for Messages

source§

impl Mappable for Receipts

§

type Key = <Receipts as Mappable>::OwnedKey

§

type OwnedKey = Bytes32

§

type Value = [Receipt]

§

type OwnedValue = Vec<Receipt, Global>

source§

impl Mappable for SealedBlockConsensus

source§

impl Mappable for SpentMessages

source§

impl Mappable for Transactions

§

type Key = <Transactions as Mappable>::OwnedKey

§

type OwnedKey = Bytes32

§

type Value = <Transactions as Mappable>::OwnedValue

§

type OwnedValue = Transaction