[−][src]Struct leveldb::database::Database
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]
name: &Path,
options: Options,
comparator: C
) -> Result<Database<K>, 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, K: Key + 'a> Iterable<'a, K> for Database<K>
[src]
ⓘImportant traits for Iterator<'a, K>fn iter(&'a self, options: ReadOptions<'a, K>) -> Iterator<K>
[src]
ⓘImportant traits for KeyIterator<'a, K>fn keys_iter(&'a self, options: ReadOptions<'a, K>) -> KeyIterator<K>
[src]
ⓘImportant traits for ValueIterator<'a, K>fn value_iter(&'a self, options: ReadOptions<'a, K>) -> ValueIterator<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]
&self,
options: WriteOptions,
key: BK,
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<BK: Borrow<K>>(
&self,
options: WriteOptions,
key: BK
) -> Result<(), Error>
[src]
&self,
options: WriteOptions,
key: BK
) -> 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<'a, BK: Borrow<K>>(
&self,
options: ReadOptions<'a, K>,
key: BK
) -> Result<Option<Vec<u8>>, Error>
[src]
&self,
options: ReadOptions<'a, K>,
key: BK
) -> Result<Option<Vec<u8>>, Error>
get a value from the database.
The passed key will be compared using the comparator.
impl<K: Key> Batch<K> for Database<K>
[src]
fn write(
&self,
options: WriteOptions,
batch: &Writebatch<K>
) -> Result<(), Error>
[src]
&self,
options: WriteOptions,
batch: &Writebatch<K>
) -> Result<(), Error>
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,
K: Unpin,
impl<K> UnwindSafe for Database<K> where
K: UnwindSafe,
K: UnwindSafe,
impl<K> RefUnwindSafe for Database<K> where
K: RefUnwindSafe,
K: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,