[][src]Struct rusty_leveldb::DB

pub struct DB { /* fields omitted */ }

DB contains the actual database implemenation. As opposed to the original, this implementation is not concurrent (yet).

Methods

impl DB[src]

pub fn open<P: AsRef<Path>>(name: P, opt: Options) -> Result<DB>[src]

Opens or creates a new or existing database. name is the name of the directory containing the database.

Whether a new database is created and what happens if a database exists at the given path depends on the options set (create_if_missing, error_if_exists).

impl DB[src]

pub fn put(&mut self, k: &[u8], v: &[u8]) -> Result<()>[src]

Adds a single entry. It's a short, non-synchronous, form of write(); in order to make sure that the written entry is on disk, call flush() afterwards.

pub fn delete(&mut self, k: &[u8]) -> Result<()>[src]

Deletes a single entry. Like with put(), you can call flush() to guarantee that the operation made it to disk.

pub fn write(&mut self, batch: WriteBatch, sync: bool) -> Result<()>[src]

Writes an entire WriteBatch. sync determines whether the write should be flushed to disk.

pub fn flush(&mut self) -> Result<()>[src]

flush makes sure that all pending changes (e.g. from put()) are stored on disk.

impl DB[src]

pub fn get_at(
    &mut self,
    snapshot: &Snapshot,
    key: &[u8]
) -> Result<Option<Vec<u8>>>
[src]

get_at reads the value for a given key at or before snapshot. It returns Ok(None) if the entry wasn't found, and Err(_) if an error occurred.

pub fn get(&mut self, key: &[u8]) -> Option<Vec<u8>>[src]

get is a simplified version of get_at(), translating errors to None.

impl DB[src]

pub fn new_iter(&mut self) -> Result<DBIterator>[src]

new_iter returns a DBIterator over the current state of the database. The iterator will not return elements added to the database after its creation.

pub fn new_iter_at(&mut self, ss: Snapshot) -> Result<DBIterator>[src]

new_iter_at returns a DBIterator at the supplied snapshot.

impl DB[src]

pub fn get_snapshot(&mut self) -> Snapshot[src]

Returns a snapshot at the current state. It can be used to retrieve entries from the database as they were at an earlier point in time.

impl DB[src]

pub fn compact_range(&mut self, from: &[u8], to: &[u8]) -> Result<()>[src]

compact_range triggers an immediate compaction on the specified key range. Repeatedly calling this without actually adding new keys is not useful.

Compactions in general will cause the database to find entries more quickly, and take up less space on disk.

Trait Implementations

impl Drop for DB[src]

Auto Trait Implementations

impl Unpin for DB

impl !Sync for DB

impl !Send for DB

impl !RefUnwindSafe for DB

impl !UnwindSafe for DB

Blanket Implementations

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

impl<T, U> Into<U> for T where
    U: From<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> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,