[][src]Struct leveldb::database::Database

pub struct Database<K: Key> { /* 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 K and comparator type C.

Multiple Database objects can be kept around, as leveldb synchronises internally.

Methods

impl<K: Key> Database<K>[src]

pub fn open(name: &Path, options: Options) -> Result<Database<K>, Error>[src]

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.

pub fn open_with_comparator<C: Comparator<K = K>>(
    name: &Path,
    options: Options,
    comparator: C
) -> Result<Database<K>, Error>
[src]

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, K: Key + 'a> Iterable<'a, K> for Database<K>[src]

impl<K: Key> Snapshots<K> for Database<K>[src]

impl<K: Key> KV<K> for Database<K>[src]

fn put<BK: Borrow<K>>(
    &self,
    options: WriteOptions,
    key: BK,
    value: &[u8]
) -> Result<(), Error>
[src]

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<BK: Borrow<K>>(
    &self,
    options: WriteOptions,
    key: BK
) -> Result<(), Error>
[src]

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<'a, BK: Borrow<K>>(
    &self,
    options: ReadOptions<'a, K>,
    key: BK
) -> Result<Option<Vec<u8>>, Error>
[src]

get a value from the database.

The passed key will be compared using the comparator.

impl<K: Key> Batch<K> for Database<K>[src]

impl<'a, K: Key + 'a> Compaction<'a, K> for Database<K>[src]

impl<K: Key> Send for Database<K>[src]

impl<K: Key> Sync for Database<K>[src]

Auto Trait Implementations

impl<K> Unpin for Database<K> where
    K: Unpin

impl<K> UnwindSafe for Database<K> where
    K: UnwindSafe

impl<K> RefUnwindSafe for Database<K> where
    K: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]