Struct rusty_leveldb::DB

source ·
pub struct DB { /* private fields */ }
Expand description

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

Implementations§

source§

impl DB

source

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

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).

source

pub fn close(&mut self) -> Result<()>

Flush data to disk and release lock.

source§

impl DB

source

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

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.

source

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

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

source

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

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

source

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

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

source§

impl DB

source

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

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.

source

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

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

source§

impl DB

source

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

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.

source

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

new_iter_at returns a DBIterator at the supplied snapshot.

source§

impl DB

source

pub fn get_snapshot(&mut self) -> Snapshot

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.

source§

impl DB

source

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

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§

source§

impl Drop for DB

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for DB

Auto Trait Implementations§

§

impl !RefUnwindSafe for DB

§

impl !Sync for DB

§

impl Unpin for DB

§

impl !UnwindSafe for DB

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V