Storable

Trait Storable 

Source
pub trait Storable:
    Clone
    + Sync
    + 'static {
    type StorageKey: Clone + Eq + Hash + Send + Sync + Debug;

    // Required methods
    fn data_type() -> StorageType;
    fn get_id(&self) -> Self::StorageKey;
    fn get_full_binary_key_id(key: &Self::StorageKey) -> Vec<u8> ;
    fn key_from_full_binary(bin: &[u8]) -> Result<Self::StorageKey, String>;

    // Provided method
    fn get_full_binary_id(&self) -> Vec<u8>  { ... }
}
Available on non-crate feature serde_serialization only.
Expand description

Storable represents an item which can be stored in the storage layer

Required Associated Types§

Source

type StorageKey: Clone + Eq + Hash + Send + Sync + Debug

This particular storage will have a key type

Required Methods§

Source

fn data_type() -> StorageType

Must return a valid storage type

Source

fn get_id(&self) -> Self::StorageKey

Retrieve an instance of the id of this storable. The combination of the storable’s StorageType and this id are globally unique

Source

fn get_full_binary_key_id(key: &Self::StorageKey) -> Vec<u8>

Retrieve the full binary version of a key (for comparisons)

Source

fn key_from_full_binary(bin: &[u8]) -> Result<Self::StorageKey, String>

Reformat a key from the full-binary specification

Provided Methods§

Source

fn get_full_binary_id(&self) -> Vec<u8>

Retrieve the full binary version of a key (for comparisons)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§