Rust · Errors

Errors

use ustore::Error;use ustore::Status;use ustore::*; 1.0.0-rc.1 · d6d40961

Every fallible call answers Result<T, Error>, where the error carries the Status the C ABI reported and the static message beside it, so nothing allocates on the failure path. A failure the binding catches before the call crosses the boundary reports the status the engine would have used. Status carries the C enumerators’ values and leaves success to Result, so an Error never carries Status::Deferred, which only Deferred::status reports, and a status a newer library added reads as Status::Internal. Status, Mood, Durability, Watch, DropMode, Isolation, Transport, Engine, Modality, Role and Modification print through Display and parse through FromStr the spellings the C tables own, such as "not-found" or "strict-serializable", so nothing is compared as a string. ustore::version() names the library the program runs against, such as "1.0.0".

match database.head().collection_find("nowhere", &mut arena) {
    Err(failure) if failure.status == ustore::Status::NotFound => println!("{}: {failure}", failure.status),
    other => { other?; }
}

API

Types

ResultThe result of every fallible call in this crate.
db.rs:955 ↗
pub type Result<Value> = Result<Value, Error>;
StructErrorA failure the library reported, or the binding caught before the call, with a static message so nothing allocates on the failure path.
db.rs:933 ↗
pub struct Error

Fields

statusStatusThe identity of the failure, shared with the C ABI.
message&'static strThe detail the status alone cannot carry.

Implements

Clone, Copy, StructuralPartialEq, PartialEq, Eq, Display, Debug, Error
EnumStatusWhat went wrong, in the vocabulary of ustore_status_t, whose success is left to Result.
db.rs:830 ↗
pub enum Status

An Error never carries Status::Deferred, which only Deferred::status reports.

Values

Deferred1A deferred call that has not finished; the one status that is never final.
OutOfMemory2An allocation could not be satisfied.
ReadOnly6The call would change a database opened read-only, as Database::view_rocksdb opens one.
Io7A file or directory could not be opened, read, written, or closed.
Device8A device could not be selected, or its memory could not be claimed.
Malformed9Stored or supplied data could not be decoded.
Internal10The engine failed in a way no other status names.
Uninitialized12The call needs a database or transaction that was never opened.
Contended14The call was refused rather than waited for.
Cancelled15A progress callback stopped the call, which published nothing.
Unsupported16The engine or build does not implement what the call asks for.
InvalidArgument17An argument is null, contradicts another one, or carries unaccepted options.
NotFound18A snapshot, collection, or document the call addresses does not exist.
AlreadyExists19A snapshot, collection, or document the call creates already exists.
WriteConflict20A concurrent writer changed a key this transaction wrote.
ReadConflict21A concurrent writer changed a key this transaction read.
PhantomConflict22A concurrent writer inserted into a range this transaction scanned.
CapacityExhausted23A hard design ceiling was reached.

Implements

Clone, Copy, StructuralPartialEq, PartialEq, Eq, Debug, Hash, Display, FromStr