Struct DB

Source
pub struct DB { /* private fields */ }
Expand description

This struct represents an open instance of the database.

Implementations§

Source§

impl DB

Source

pub fn open(path: &Path) -> LevelDBResult<DB>

Open a database at the given path. Returns a Result indicating whether the database could be opened. Note that this function will not create the database at the given location if it does not exist.

Source

pub fn create(path: &Path) -> LevelDBResult<DB>

Create and returns a database at the given path.

Source

pub fn open_with_opts(path: &Path, opts: DBOptions) -> LevelDBResult<DB>

Open a database at the given path, using the provided options to control the open behaviour. Returns a Result indicating whether or not the database could be opened.

Source

pub fn put(&mut self, key: &[u8], val: &[u8]) -> LevelDBResult<()>

Set the database entry for “key” to “value”. Returns a result indicating the success or failure of the operation.

Source

pub fn put_opts( &mut self, key: &[u8], val: &[u8], opts: DBWriteOptions, ) -> LevelDBResult<()>

Set the database entry for “key” to “value”. Allows specifying the write options to use for this operaton.

Source

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

Remove the database entry (if any) for “key”. Returns a result indicating the success of the operation. It is not an error if “key” did not exist in the database.

Source

pub fn delete_opts( &mut self, key: &[u8], opts: DBWriteOptions, ) -> LevelDBResult<()>

Remove the database entry (if any) for “key”. As delete(), but allows specifying the write options to use for this operation.

Source

pub fn write(&mut self, batch: DBWriteBatch) -> LevelDBResult<()>

Apply the specified updates to the database, as given in the provided DBWriteBatch. Returns a result indicating the success of the operation.

Source

pub fn write_opts( &mut self, batch: DBWriteBatch, opts: DBWriteOptions, ) -> LevelDBResult<()>

Apply the given write batch. As write(), but allows specifying the write options to use for this operation.

Source

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

If the database contains an entry for “key”, return the associated value

  • otherwise, return None. This value is wrapped in a Result to indicate if an error occurred.
Source

pub fn get_opts( &self, key: &[u8], opts: DBReadOptions, ) -> LevelDBResult<Option<Vec<u8>>>

Get the value for a given key. As get(), but allows specifying the options to use when reading.

Source

pub fn iter(&mut self) -> LevelDBResult<DBIterator>

Return an iterator over the database.

Source

pub fn snapshot(&self) -> DBSnapshot

Return a snapshot of the database.

Trait Implementations§

Source§

impl Clone for DB

Source§

fn clone(&self) -> DB

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Send for DB

Source§

impl Sync for DB

Auto Trait Implementations§

§

impl Freeze for DB

§

impl !RefUnwindSafe for DB

§

impl Unpin for DB

§

impl !UnwindSafe for DB

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.