[−][src]Struct tari_storage::lmdb_store::LMDBDatabase
Implementations
impl LMDBDatabase
[src]
pub fn insert<K: ?Sized, V>(&self, key: &K, value: &V) -> Result<(), LMDBError> where
K: AsLmdbBytes,
V: Serialize,
[src]
K: AsLmdbBytes,
V: Serialize,
Inserts a record into the database. This is an atomic operation. Internally, insert
creates a new
write transaction, writes the value, and then commits the transaction.
pub fn get<K: ?Sized, V>(&self, key: &K) -> Result<Option<V>, LMDBError> where
K: AsLmdbBytes,
V: DeserializeOwned,
[src]
K: AsLmdbBytes,
V: DeserializeOwned,
Get a value from the database. This is an atomic operation. A read transaction is created, the value
extracted, copied and converted to V before closing the transaction. A copy is unavoidable because the
extracted byte string is released when the transaction is closed. If you are doing many gets
, it is more
efficient to use with_read_transaction
pub fn get_stats(&self) -> Result<Stat, LMDBError>
[src]
Return statistics about the database, See Stat for more details.
pub fn log_info(&self)
[src]
Log some pretty printed stats.See Stat for more details.
pub fn is_empty(&self) -> Result<bool, LMDBError>
[src]
Returns if the database is empty.
pub fn len(&self) -> Result<usize, LMDBError>
[src]
Returns the total number of entries in this database.
pub fn for_each<K, V, F>(&self, f: F) -> Result<(), LMDBError> where
K: DeserializeOwned,
V: DeserializeOwned,
F: FnMut(Result<(K, V), KeyValStoreError>) -> IterationResult,
[src]
K: DeserializeOwned,
V: DeserializeOwned,
F: FnMut(Result<(K, V), KeyValStoreError>) -> IterationResult,
Execute function f
for each value in the database.
The underlying LMDB library does not permit database cursors to be returned from functions to preserve Rust memory guarantees, so this is the closest thing to an iterator that you're going to get :/
f
is a closure of form |pair: Result<(K,V), LMDBError>| -> IterationResult
. If IterationResult::Break
is
returned the closure will not be called again and for_each
will return. You will usually need to include
type inference to let Rust know which type to deserialise to:
let res = db.for_each::<Key, User, _>(|pair| {
let (key, user) = pair.unwrap();
//.. do stuff with key and user..
});
pub fn contains_key<K: ?Sized>(&self, key: &K) -> Result<bool, LMDBError> where
K: AsLmdbBytes,
[src]
K: AsLmdbBytes,
Checks whether a key exists in this database
pub fn remove<K: ?Sized>(&self, key: &K) -> Result<(), LMDBError> where
K: AsLmdbBytes,
[src]
K: AsLmdbBytes,
Delete a record associated with key
from the database. If the key is not found,
pub fn with_read_transaction<F, V>(
&self,
f: F
) -> Result<Option<Vec<V>>, LMDBError> where
V: DeserializeOwned,
F: FnOnce(LMDBReadTransaction<'_, '_>) -> Result<Option<Vec<V>>, LMDBError>,
[src]
&self,
f: F
) -> Result<Option<Vec<V>>, LMDBError> where
V: DeserializeOwned,
F: FnOnce(LMDBReadTransaction<'_, '_>) -> Result<Option<Vec<V>>, LMDBError>,
Create a read-only transaction on the current database and execute the instructions given in the closure. The
transaction is automatically committed when the closure goes out of scope. You may provide the results of the
transaction to the calling scope by populating a Vec<V>
with the results of txn.get(k)
. Otherwise, if the
results are not needed, or you did not call get
, just return Ok(None)
.
pub fn with_write_transaction<F>(&self, f: F) -> Result<(), LMDBError> where
F: FnOnce(LMDBWriteTransaction<'_, '_>) -> Result<(), LMDBError>,
[src]
F: FnOnce(LMDBWriteTransaction<'_, '_>) -> Result<(), LMDBError>,
Create a transaction with write access on the current table.
pub fn db(&self) -> Arc<Database<'static>>
[src]
Returns an owned atomic reference to the database
Trait Implementations
impl Clone for LMDBDatabase
[src]
fn clone(&self) -> LMDBDatabase
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl !RefUnwindSafe for LMDBDatabase
impl Send for LMDBDatabase
impl Sync for LMDBDatabase
impl Unpin for LMDBDatabase
impl !UnwindSafe for LMDBDatabase
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T> DefaultFeatures<'a> for T where
T: 'a + Clone + Send + Sync,
T: 'a + Clone + Send + Sync,
fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a> + 'a>
fn self_address_mut(&mut self) -> *mut ()
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<'a, T> NonSyncFeatures<'a> for T where
T: 'a + Clone,
T: 'a + Clone,
fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a> + 'a>
fn self_address_mut(&mut self) -> *mut ()
impl<T> SafeBorrow<T> for T where
T: ?Sized,
T: ?Sized,
fn borrow_replacement(ptr: &T) -> &T
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,