Database

Trait Database 

Source
pub trait Database: Send + Sync {
    // Required methods
    fn get(
        &self,
        column_family: &str,
        key: &[u8],
    ) -> Result<Option<Vec<u8>>, DatabaseError>;
    fn put(
        &self,
        column_family: &str,
        key: &[u8],
        value: &[u8],
    ) -> Result<(), DatabaseError>;
    fn delete(
        &self,
        column_family: &str,
        key: &[u8],
    ) -> Result<(), DatabaseError>;
    fn iter_prefix(
        &self,
        column_family: &str,
        prefix: &[u8],
    ) -> Result<Vec<(Vec<u8>, Vec<u8>)>, DatabaseError>;
}
Expand description

Database trait for abstracting storage operations Implementations can use RocksDB, in-memory storage, or other backends

Required Methods§

Source

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

Get a value from the database

Source

fn put( &self, column_family: &str, key: &[u8], value: &[u8], ) -> Result<(), DatabaseError>

Put a key-value pair into the database

Source

fn delete(&self, column_family: &str, key: &[u8]) -> Result<(), DatabaseError>

Delete a key from the database

Source

fn iter_prefix( &self, column_family: &str, prefix: &[u8], ) -> Result<Vec<(Vec<u8>, Vec<u8>)>, DatabaseError>

Iterate over keys with a given prefix

Implementors§