pub struct Tdb(/* private fields */);
Expand description
A handle to a TDB database.
Implementations§
Source§impl Tdb
impl Tdb
Sourcepub fn open<P: AsRef<Path>>(
name: P,
hash_size: Option<u32>,
tdb_flags: Flags,
open_flags: i32,
mode: c_uint,
) -> Option<Tdb>
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.
Sourcepub fn memory(hash_size: Option<u32>, tdb_flags: Flags) -> Option<Tdb>
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:
Sourcepub fn set_max_dead(&mut self, max_dead: u32)
pub fn set_max_dead(&mut self, max_dead: u32)
Set the maximum number of dead records per hash chain.
Sourcepub fn reopen(&mut self) -> Result<(), Error>
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.
Sourcepub fn store(
&mut self,
key: &[u8],
val: &[u8],
flags: Option<StoreFlags>,
) -> Result<(), Error>
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.
Sourcepub fn append(&mut self, key: &[u8], val: &[u8]) -> Result<(), Error>
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.
Sourcepub fn keys(&self) -> impl Iterator<Item = Vec<u8>> + '_
pub fn keys(&self) -> impl Iterator<Item = Vec<u8>> + '_
Iterate over all keys in the database.
Sourcepub fn iter(&self) -> impl Iterator<Item = (Vec<u8>, Vec<u8>)> + '_
pub fn iter(&self) -> impl Iterator<Item = (Vec<u8>, Vec<u8>)> + '_
Iterate over all key/value pairs in the database.
Sourcepub fn lockall_nonblock(&self) -> Result<(), Error>
pub fn lockall_nonblock(&self) -> Result<(), Error>
Lock the database, non-blocking
Sourcepub fn lockall_read(&self) -> Result<(), Error>
pub fn lockall_read(&self) -> Result<(), Error>
Lock the database for reading
Sourcepub fn lockall_read_nonblock(&self) -> Result<(), Error>
pub fn lockall_read_nonblock(&self) -> Result<(), Error>
Lock the database for reading, non-blocking
Sourcepub fn get_seqnum(&self) -> u64
pub fn get_seqnum(&self) -> u64
Return the current sequence number
Sourcepub fn remove_flags(&mut self, flags: Flags)
pub fn remove_flags(&mut self, flags: Flags)
Remove a flag
Sourcepub fn enable_seqnum(&mut self)
pub fn enable_seqnum(&mut self)
Enable sequence numbers
Sourcepub fn increment_seqnum_nonblock(&mut self)
pub fn increment_seqnum_nonblock(&mut self)
Increment the sequence number
Sourcepub fn freelist_size(&self) -> u32
pub fn freelist_size(&self) -> u32
Return the freelist size
Sourcepub fn transaction_start(&mut self) -> Result<(), Error>
pub fn transaction_start(&mut self) -> Result<(), Error>
Start a new transaction
Sourcepub fn transaction_active(&self) -> bool
pub fn transaction_active(&self) -> bool
Check if a transaction is active
Sourcepub fn transaction_start_nonblock(&mut self) -> Result<(), Error>
pub fn transaction_start_nonblock(&mut self) -> Result<(), Error>
Start a new transaction, non-blocking
Sourcepub fn transaction_prepare_commit(&mut self) -> Result<(), Error>
pub fn transaction_prepare_commit(&mut self) -> Result<(), Error>
Prepare to commit a transaction
Sourcepub fn transaction_commit(&mut self) -> Result<(), Error>
pub fn transaction_commit(&mut self) -> Result<(), Error>
Commit a transaction
Sourcepub fn transaction_cancel(&mut self) -> Result<(), Error>
pub fn transaction_cancel(&mut self) -> Result<(), Error>
Cancel a transaction