Struct exonum_leveldb::database::Database
[−]
[src]
pub struct Database { /* fields omitted */ }
The main database object.
leveldb databases are based on ordered keys. By default, leveldb orders
by the binary value of the key. Additionally, a custom Comparator
can
be passed when opening the database. This library ships with an Comparator
implementation for keys that are Ord
.
When re-CString
a database, you must use the same key type &[u8] and
comparator type C
.
Multiple Database objects can be kept around, as leveldb synchronises internally.
Methods
impl Database
[src]
fn open(name: &Path, options: Options) -> Result<Database, Error>
Open a new database
If the database is missing, the behaviour depends on options.create_if_missing
.
The database will be created using the settings given in options
.
fn open_with_comparator<C: Comparator>(
name: &Path,
options: Options,
comparator: C
) -> Result<Database, Error>
name: &Path,
options: Options,
comparator: C
) -> Result<Database, Error>
Open a new database with a custom comparator
If the database is missing, the behaviour depends on options.create_if_missing
.
The database will be created using the settings given in options
.
The comparator must implement a total ordering over the keyspace.
For keys that implement Ord, consider the OrdComparator
.
Trait Implementations
impl<'a> Iterable<'a> for Database
[src]
fn iter(&'a self, options: ReadOptions<'a>) -> Iterator
Return an Iterator iterating over (Key,Value) pairs
impl Snapshots for Database
[src]
impl KV for Database
[src]
fn put<K: AsRef<[u8]>>(
&self,
options: WriteOptions,
key: K,
value: &[u8]
) -> Result<(), Error>
&self,
options: WriteOptions,
key: K,
value: &[u8]
) -> Result<(), Error>
put a binary value into the database.
If the key is already present in the database, it will be overwritten.
The passed key will be compared using the comparator.
The database will be synced to disc if options.sync == true
. This is
NOT the default.
fn delete<K: AsRef<[u8]>>(
&self,
options: WriteOptions,
key: K
) -> Result<(), Error>
&self,
options: WriteOptions,
key: K
) -> Result<(), Error>
delete a value from the database.
The passed key will be compared using the comparator.
The database will be synced to disc if options.sync == true
. This is
NOT the default.
fn get<K: AsRef<[u8]>>(
&self,
options: ReadOptions,
key: K
) -> Result<Option<Vec<u8>>, Error>
&self,
options: ReadOptions,
key: K
) -> Result<Option<Vec<u8>>, Error>
get a value from the database.
The passed key will be compared using the comparator.
impl Batch for Database
[src]
fn write(&self, options: WriteOptions, batch: &Writebatch) -> Result<(), Error>
Write a batch to the database, ensuring success for all items or an error