pub struct ThetaDB { /* private fields */ }
Expand description
The main database struct, all entry points are here.
Implementations§
source§impl ThetaDB
impl ThetaDB
sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open a ThetaDB instance at the given file path with default options.
sourcepub fn open_with_options(
path: impl AsRef<Path>,
options: Options
) -> Result<Self>
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.
sourcepub fn contains(&self, key: impl AsRef<[u8]>) -> Result<bool>
pub fn contains(&self, key: impl AsRef<[u8]>) -> Result<bool>
Check if the ThetaDB contains a given key.
sourcepub fn get(&self, key: impl AsRef<[u8]>) -> Result<Option<Vec<u8>>>
pub fn get(&self, key: impl AsRef<[u8]>) -> Result<Option<Vec<u8>>>
Get the value associated with a given key.
sourcepub fn put(&self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>) -> Result<()>
pub fn put(&self, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>) -> Result<()>
Insert or update a key-value pair into the ThetaDB.
sourcepub fn delete(&self, key: impl AsRef<[u8]>) -> Result<()>
pub fn delete(&self, key: impl AsRef<[u8]>) -> Result<()>
Delete a key-value pair from the ThetaDB.
sourcepub fn view<T>(&self, f: impl FnOnce(&Tx<'_>) -> Result<T>) -> Result<T>
pub fn view<T>(&self, f: impl FnOnce(&Tx<'_>) -> Result<T>) -> Result<T>
Perform a read-only transaction using closure on the ThetaDB.
sourcepub fn update<T>(
&self,
f: impl FnOnce(&mut TxMut<'_>) -> Result<T>
) -> Result<T>
pub fn update<T>( &self, f: impl FnOnce(&mut TxMut<'_>) -> Result<T> ) -> Result<T>
Perform a read-write transaction using closure on the ThetaDB.
sourcepub fn begin_tx_mut(&self) -> Result<TxMut<'_>>
pub fn begin_tx_mut(&self) -> Result<TxMut<'_>>
Start a read-write transaction.
sourcepub fn first_cursor(&self) -> Result<CursorTx<'_>>
pub fn first_cursor(&self) -> Result<CursorTx<'_>>
Get the cursor pointing to the first record in the ThetaDB.
sourcepub fn last_cursor(&self) -> Result<CursorTx<'_>>
pub fn last_cursor(&self) -> Result<CursorTx<'_>>
Get the cursor pointing to the last record in the ThetaDB.
sourcepub fn cursor_from_key(&self, key: &[u8]) -> Result<CursorTx<'_>>
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.
Auto Trait Implementations§
impl !Freeze for ThetaDB
impl RefUnwindSafe for ThetaDB
impl Send for ThetaDB
impl Sync for ThetaDB
impl Unpin for ThetaDB
impl UnwindSafe for ThetaDB
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more