Struct foundationdb::database::Database
source · pub struct Database { /* private fields */ }
Expand description
Represents a FoundationDB database — a mutable, lexicographically ordered mapping from binary keys to binary values.
Modifications to a database are performed via transactions.
Implementations§
source§impl Database
impl Database
sourcepub fn set_option(&self, opt: DatabaseOption) -> Result<()>
pub fn set_option(&self, opt: DatabaseOption) -> Result<()>
Called to set an option an on Database
.
sourcepub fn create_trx(&self) -> Result<Transaction>
pub fn create_trx(&self) -> Result<Transaction>
Creates a new transaction on the given database.
sourcepub fn transact<F, Fut, Item, Error>(
&self,
f: F
) -> Box<dyn Future<Item = Fut::Item, Error = Error>>where
F: FnMut(Transaction) -> Fut + 'static,
Fut: IntoFuture<Item = Item, Error = Error> + 'static,
Item: 'static,
Error: From<FdbError> + 'static,
pub fn transact<F, Fut, Item, Error>(
&self,
f: F
) -> Box<dyn Future<Item = Fut::Item, Error = Error>>where
F: FnMut(Transaction) -> Fut + 'static,
Fut: IntoFuture<Item = Item, Error = Error> + 'static,
Item: 'static,
Error: From<FdbError> + 'static,
transact
returns a future which retries on error. It tries to resolve a future created by
caller-provided function f
inside a retry loop, providing it with a newly created
transaction. After caller-provided future resolves, the transaction will be committed
automatically.
Warning
It might retry indefinitely if the transaction is highly contentious. It is recommended to
set TransactionOption::RetryLimit
or TransactionOption::SetTimeout
on the transaction
if the task need to be guaranteed to finish.