pub fn boot() -> FdbResult<NetworkAutoStop>Expand description
Initialize the FoundationDB Client API and start the network thread.
Safe and idempotent: calling it multiple times returns Ok as long as the
(default) API version matches. Calling it is optional: creating a Database
initializes the client automatically. The network runs until process exit,
where an atexit hook stops it and joins the network thread, or until an
explicit api::stop_network call.
The returned guard is kept for backward compatibility, dropping it does nothing.
The automatic stop at process exit is a convenience suited to tests and
short-lived tools. In a production application, prefer handling the network
stop yourself: the network thread is the event loop driving every
transaction, you may still have on-going operations at exit time, and you
usually want a clean teardown. Finish or cancel your work, drop your
Database handles, then call api::stop_network.
§Errors
- error 2201 (
api_version_already_set) if a different API version was selected before - error 2025 (
network_cannot_be_restarted) if the network was stopped
§Examples
foundationdb::boot().expect("failed to initialize FoundationDB");
// do some interesting things with the API...#[tokio::main]
async fn main() {
foundationdb::boot().expect("failed to initialize FoundationDB");
// do some interesting things with the API...
}