[][src]Trait blockchain_traits::KVStore

pub trait KVStore {
    type Address: Address;
    fn contains(
        &self,
        address: &Self::Address,
        key: &[u8]
    ) -> Result<bool, KVError>;
fn size(&self, address: &Self::Address, key: &[u8]) -> Result<u64, KVError>;
fn get(
        &self,
        address: &Self::Address,
        key: &[u8]
    ) -> Result<Option<&[u8]>, KVError>;
fn set(
        &mut self,
        address: &Self::Address,
        key: Vec<u8>,
        value: Vec<u8>
    ) -> Result<(), KVError>; }

Interface for a Blockchain-flavored key-value store. The semantics of address = Address::default() are context-dependent but generally refer to the address of the current callee.

Associated Types

Loading content...

Required methods

fn contains(&self, address: &Self::Address, key: &[u8]) -> Result<bool, KVError>

Returns whether the key is present in account storage.

fn size(&self, address: &Self::Address, key: &[u8]) -> Result<u64, KVError>

Returns the size of the data stored in the account at addr under the given key.

fn get(
    &self,
    address: &Self::Address,
    key: &[u8]
) -> Result<Option<&[u8]>, KVError>

Returns the data stored in the account at addr under the given key.

fn set(
    &mut self,
    address: &Self::Address,
    key: Vec<u8>,
    value: Vec<u8>
) -> Result<(), KVError>

Sets the data stored in the account at addr under the given key. Overwrites any existing data.

Loading content...

Implementors

Loading content...