fuel_core_storage::blueprint

Trait BlueprintInspect

source
pub trait BlueprintInspect<M, S>{
    type KeyCodec: Encode<M::Key> + Decode<M::OwnedKey>;
    type ValueCodec: Encode<M::Value> + Decode<M::OwnedValue>;

    // Provided methods
    fn exists(
        storage: &S,
        key: &M::Key,
        column: S::Column,
    ) -> StorageResult<bool> { ... }
    fn size_of_value(
        storage: &S,
        key: &M::Key,
        column: S::Column,
    ) -> StorageResult<Option<usize>> { ... }
    fn get(
        storage: &S,
        key: &M::Key,
        column: S::Column,
    ) -> StorageResult<Option<M::OwnedValue>> { ... }
}
Expand description

This trait allows defining the agnostic implementation for all storage traits(StorageInspect, StorageMutate, etc) while the main logic is hidden inside the blueprint. It allows quickly adding support for new structures only by implementing the trait and reusing the existing infrastructure in other places. It allows changing the blueprint on the fly in the definition of the table without affecting other areas of the codebase.

The blueprint is responsible for encoding/decoding(usually it is done via KeyCodec and ValueCodec) the key and value and putting/extracting it to/from the storage.

Required Associated Types§

source

type KeyCodec: Encode<M::Key> + Decode<M::OwnedKey>

The codec used to encode and decode storage key.

source

type ValueCodec: Encode<M::Value> + Decode<M::OwnedValue>

The codec used to encode and decode storage value.

Provided Methods§

source

fn exists(storage: &S, key: &M::Key, column: S::Column) -> StorageResult<bool>

Checks if the value exists in the storage.

source

fn size_of_value( storage: &S, key: &M::Key, column: S::Column, ) -> StorageResult<Option<usize>>

Returns the size of the value in the storage.

source

fn get( storage: &S, key: &M::Key, column: S::Column, ) -> StorageResult<Option<M::OwnedValue>>

Returns the value from the storage.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<M, S, KeyCodec, ValueCodec> BlueprintInspect<M, S> for Plain<KeyCodec, ValueCodec>
where M: Mappable, S: KeyValueInspect, KeyCodec: Encode<M::Key> + Decode<M::OwnedKey>, ValueCodec: Encode<M::Value> + Decode<M::OwnedValue>,

source§

type KeyCodec = KeyCodec

source§

type ValueCodec = ValueCodec

source§

impl<M, S, KeyCodec, ValueCodec, Metadata, Nodes, Encoder> BlueprintInspect<M, S> for Merklized<KeyCodec, ValueCodec, Metadata, Nodes, Encoder>
where M: Mappable, S: KeyValueInspect, KeyCodec: Encode<M::Key> + Decode<M::OwnedKey>, ValueCodec: Encode<M::Value> + Decode<M::OwnedValue>,

source§

type KeyCodec = KeyCodec

source§

type ValueCodec = ValueCodec

source§

impl<M, S, KeyCodec, ValueCodec, Metadata, Nodes, KeyConverter> BlueprintInspect<M, S> for Sparse<KeyCodec, ValueCodec, Metadata, Nodes, KeyConverter>
where M: Mappable, S: KeyValueInspect, KeyCodec: Encode<M::Key> + Decode<M::OwnedKey>, ValueCodec: Encode<M::Value> + Decode<M::OwnedValue>,

source§

type KeyCodec = KeyCodec

source§

type ValueCodec = ValueCodec