Struct Tdb

Source
pub struct Tdb(/* private fields */);
Expand description

A handle to a TDB database.

Implementations§

Source§

impl Tdb

Source

pub fn open<P: AsRef<Path>>( name: P, hash_size: Option<u32>, tdb_flags: Flags, open_flags: i32, mode: c_uint, ) -> Option<Tdb>

Open the database and creating it if necessary.

§Arguments
  • name - The name of the db to open.
  • hash_size - The hash size is advisory, leave None for a default.
  • tdb_flags The flags to use to open the db:
  • open_flags Flags for the open(2) function.
  • mode The mode to use for the open(2) function.
Source

pub fn memory(hash_size: Option<u32>, tdb_flags: Flags) -> Option<Tdb>

Create a database in memory

§Arguments
  • hash_size - The hash size is advisory, leave None for a default.
  • tdb_flags The flags to use to open the db:
Source

pub fn set_max_dead(&mut self, max_dead: u32)

Set the maximum number of dead records per hash chain.

Source

pub fn reopen(&mut self) -> Result<(), Error>

Reopen the database

This can be used to reopen a database after a fork, to ensure that we have an independent seek pointer and to re-establish any locks.

Source

pub fn fetch(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Error>

Fetch a value from the database.

§Arguments
  • key - The key to fetch.
§Returns
  • Ok(Some(value)) - The value associated with the key.
  • Ok(None) - The key was not found.
  • Err(e) - An error occurred.
Source

pub fn store( &mut self, key: &[u8], val: &[u8], flags: Option<StoreFlags>, ) -> Result<(), Error>

Store a key/value pair in the database.

§Arguments
  • key - The key to store.
  • val - The value to store.
  • flags - The flags to use when storing the value.
Source

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

Delete a key from the database.

§Arguments
  • key - The key to delete
Source

pub fn append(&mut self, key: &[u8], val: &[u8]) -> Result<(), Error>

Append a value to an existing key.

§Arguments
  • key - The key to append to.
  • val - The value to append.
Source

pub fn keys(&self) -> impl Iterator<Item = Vec<u8>> + '_

Iterate over all keys in the database.

Source

pub fn iter(&self) -> impl Iterator<Item = (Vec<u8>, Vec<u8>)> + '_

Iterate over all key/value pairs in the database.

Source

pub fn exists(&self, key: &[u8]) -> bool

Check if a particular key exists

Source

pub fn lockall(&self) -> Result<(), Error>

Lock the database

Source

pub fn unlockall(&self) -> Result<(), Error>

Unlock the database

Source

pub fn lockall_nonblock(&self) -> Result<(), Error>

Lock the database, non-blocking

Source

pub fn lockall_read(&self) -> Result<(), Error>

Lock the database for reading

Source

pub fn lockall_read_nonblock(&self) -> Result<(), Error>

Lock the database for reading, non-blocking

Source

pub fn name(&self) -> &str

Return the name of the database

Source

pub fn hash_size(&self) -> u32

Return the hash size used by the database

Source

pub fn map_size(&self) -> u32

Return the map size used by the database

Source

pub fn get_seqnum(&self) -> u64

Return the current sequence number

Source

pub fn get_flags(&self) -> Flags

Return the current flags

Source

pub fn add_flags(&mut self, flags: Flags)

Add a flag

Source

pub fn remove_flags(&mut self, flags: Flags)

Remove a flag

Source

pub fn enable_seqnum(&mut self)

Enable sequence numbers

Source

pub fn increment_seqnum_nonblock(&mut self)

Increment the sequence number

Source

pub fn repack(&mut self) -> Result<(), Error>

Repack the database

Source

pub fn wipe_all(&mut self) -> Result<(), Error>

Wipe the database

Source

pub fn summary(&self) -> String

Return a string summarizing the database

Source

pub fn freelist_size(&self) -> u32

Return the freelist size

Source

pub fn transaction_start(&mut self) -> Result<(), Error>

Start a new transaction

Source

pub fn transaction_active(&self) -> bool

Check if a transaction is active

Source

pub fn transaction_start_nonblock(&mut self) -> Result<(), Error>

Start a new transaction, non-blocking

Source

pub fn transaction_prepare_commit(&mut self) -> Result<(), Error>

Prepare to commit a transaction

Source

pub fn transaction_commit(&mut self) -> Result<(), Error>

Commit a transaction

Source

pub fn transaction_cancel(&mut self) -> Result<(), Error>

Cancel a transaction

Trait Implementations§

Source§

impl AsRawFd for Tdb

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
Source§

impl Drop for Tdb

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Tdb

§

impl RefUnwindSafe for Tdb

§

impl !Send for Tdb

§

impl !Sync for Tdb

§

impl Unpin for Tdb

§

impl UnwindSafe for Tdb

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>,

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.