Skip to main content

ModuleTree

Trait ModuleTree 

Source
pub trait ModuleTree: Send + Sync {
    // Required methods
    fn insert(&self, key: &[u8], value: &[u8]) -> Result<()>;
    fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>>;
    fn remove(&self, key: &[u8]) -> Result<()>;
    fn iter(&self) -> Box<dyn Iterator<Item = Result<ModuleKvPair>> + Send + '_>;
}
Expand description

Key-value tree interface for module storage.

Minimal interface that both native (Database) and WASM (host calls) can implement.

Required Methods§

Source

fn insert(&self, key: &[u8], value: &[u8]) -> Result<()>

Insert a key-value pair.

Source

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

Get a value by key.

Source

fn remove(&self, key: &[u8]) -> Result<()>

Remove a key.

Source

fn iter(&self) -> Box<dyn Iterator<Item = Result<ModuleKvPair>> + Send + '_>

Iterate over all key-value pairs.

Implementors§