[−][src]Trait kvdb_web::KeyValueDB
Generic key-value database.
The KeyValueDB
deals with "column families", which can be thought of as distinct
stores within a database. Keys written in one column family will not be accessible from
any other. The number of column families must be specified at initialization, with a
differing interface for each database.
The API laid out here, along with the Sync
bound implies interior synchronization for
implementation.
Required methods
pub fn get(
&self,
col: u32,
key: &[u8]
) -> Result<Option<Vec<u8, Global>>, Error>
[src]
&self,
col: u32,
key: &[u8]
) -> Result<Option<Vec<u8, Global>>, Error>
Get a value by key.
pub fn get_by_prefix(
&self,
col: u32,
prefix: &[u8]
) -> Option<Box<[u8], Global>>
[src]
&self,
col: u32,
prefix: &[u8]
) -> Option<Box<[u8], Global>>
Get the first value matching the given prefix.
pub fn write(&self, transaction: DBTransaction) -> Result<(), Error>
[src]
Write a transaction of changes to the backing store.
pub fn iter(
&'a self,
col: u32
) -> Box<dyn Iterator<Item = (Box<[u8], Global>, Box<[u8], Global>)> + 'a, Global>
[src]
&'a self,
col: u32
) -> Box<dyn Iterator<Item = (Box<[u8], Global>, Box<[u8], Global>)> + 'a, Global>
Iterate over the data for a given column.
pub fn iter_with_prefix(
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8], Global>, Box<[u8], Global>)> + 'a, Global>
[src]
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8], Global>, Box<[u8], Global>)> + 'a, Global>
Iterate over the data for a given column, returning all key/value pairs where the key starts with the given prefix.
pub fn restore(&self, new_db: &str) -> Result<(), Error>
[src]
Attempt to replace this database with a new one located at the given path.
Provided methods
pub fn transaction(&self) -> DBTransaction
[src]
Helper to create a new transaction.
pub fn io_stats(&self, _kind: Kind) -> IoStats
[src]
Query statistics.
Not all kvdb implementations are able or expected to implement this, so by default, empty statistics is returned. Also, not all kvdb implementation can return every statistic or configured to do so (some statistics gathering may impede the performance and might be off by default).
pub fn has_key(&self, col: u32, key: &[u8]) -> Result<bool, Error>
[src]
Check for the existence of a value by key.
pub fn has_prefix(&self, col: u32, prefix: &[u8]) -> bool
[src]
Check for the existence of a value by prefix.
Implementations on Foreign Types
impl KeyValueDB for InMemory
[src]
pub fn get(
&self,
col: u32,
key: &[u8]
) -> Result<Option<Vec<u8, Global>>, Error>
[src]
&self,
col: u32,
key: &[u8]
) -> Result<Option<Vec<u8, Global>>, Error>
pub fn get_by_prefix(
&self,
col: u32,
prefix: &[u8]
) -> Option<Box<[u8], Global>>
[src]
&self,
col: u32,
prefix: &[u8]
) -> Option<Box<[u8], Global>>
pub fn write(&self, transaction: DBTransaction) -> Result<(), Error>
[src]
pub fn iter(
&'a self,
col: u32
) -> Box<dyn Iterator<Item = (Box<[u8], Global>, Box<[u8], Global>)> + 'a, Global>
[src]
&'a self,
col: u32
) -> Box<dyn Iterator<Item = (Box<[u8], Global>, Box<[u8], Global>)> + 'a, Global>
pub fn iter_with_prefix(
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8], Global>, Box<[u8], Global>)> + 'a, Global>
[src]
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8], Global>, Box<[u8], Global>)> + 'a, Global>
pub fn restore(&self, _new_db: &str) -> Result<(), Error>
[src]
Implementors
impl KeyValueDB for Database
[src]
fn get(&self, col: u32, key: &[u8]) -> Result<Option<DBValue>>
[src]
fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option<Box<[u8]>>
[src]
fn write(&self, transaction: DBTransaction) -> Result<()>
[src]
fn iter<'a>(
&'a self,
col: u32
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
[src]
&'a self,
col: u32
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
fn iter_with_prefix<'a>(
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
[src]
&'a self,
col: u32,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>