[][src]Trait cosmwasm_vm::Storage

pub trait Storage {
    pub fn get(&self, key: &[u8]) -> BackendResult<Option<Vec<u8>>>;
pub fn set(&mut self, key: &[u8], value: &[u8]) -> BackendResult<()>;
pub fn remove(&mut self, key: &[u8]) -> BackendResult<()>; }

Access to the VM's backend storage, i.e. the chain

Required methods

pub fn get(&self, key: &[u8]) -> BackendResult<Option<Vec<u8>>>

Returns Err on error. Returns Ok(None) when key does not exist. Returns Ok(Some(Vec)) when key exists.

Note: Support for differentiating between a non-existent key and a key with empty value is not great yet and might not be possible in all backends. But we're trying to get there.

pub fn set(&mut self, key: &[u8], value: &[u8]) -> BackendResult<()>

pub fn remove(&mut self, key: &[u8]) -> BackendResult<()>

Removes a database entry at key.

The current interface does not allow to differentiate between a key that existed before and one that didn't exist. See https://github.com/CosmWasm/cosmwasm/issues/290

Loading content...

Implementors

impl Storage for MockStorage[src]

Loading content...