Struct thetadb::ThetaDB

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

The main database struct, all entry points are here.

Implementations§

source§

impl ThetaDB

source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open a ThetaDB instance at the given file path with default options.

source

pub fn open_with_options( path: impl AsRef<Path>, options: Options ) -> Result<Self>

Open a ThetaDB instance at the given file path with the provided options.

source

pub fn options(&self) -> Options

Options used to configure the ThetaDB.

source

pub fn contains(&self, key: impl AsRef<[u8]>) -> Result<bool>

Check if the ThetaDB contains a given key.

source

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

Get the value associated with a given key.

source

pub fn put(&self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>) -> Result<()>

Insert or update a key-value pair into the ThetaDB.

source

pub fn delete(&self, key: impl AsRef<[u8]>) -> Result<()>

Delete a key-value pair from the ThetaDB.

source

pub fn view<T>(&self, f: impl FnOnce(&Tx<'_>) -> Result<T>) -> Result<T>

Perform a read-only transaction using closure on the ThetaDB.

source

pub fn update<T>( &self, f: impl FnOnce(&mut TxMut<'_>) -> Result<T> ) -> Result<T>

Perform a read-write transaction using closure on the ThetaDB.

source

pub fn begin_tx(&self) -> Result<Tx<'_>>

Start a read-only transaction.

source

pub fn begin_tx_mut(&self) -> Result<TxMut<'_>>

Start a read-write transaction.

source

pub fn first_cursor(&self) -> Result<CursorTx<'_>>

Get the cursor pointing to the first record in the ThetaDB.

source

pub fn last_cursor(&self) -> Result<CursorTx<'_>>

Get the cursor pointing to the last record in the ThetaDB.

source

pub fn cursor_from_key(&self, key: &[u8]) -> Result<CursorTx<'_>>

Get the cursor pointing to the specific record in the ThetaDB with the given key.

source§

impl ThetaDB

source

pub fn debugger(&self) -> Result<Debugger<'_>>

Get a debugger for the ThetaDB.

Auto Trait Implementations§

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