Rust · Errors

Errors

use uform::Error;use uform::Status;use uform::*; 4.0.0-rc.1 · 3ee5e534

Every fallible call returns uform::Result, whose Error carries a Status and a static message, so nothing allocates on the failure path. A failure the binding catches before the call crosses the boundary reports the status the library would have used.

match model.on(&executor).text_encode(&texts, Outputs::EMBEDDINGS, Scalar::F32, &mut arena) {
    Ok(encoded) => println!("{} items", encoded.embeddings.map_or(0, |rows| rows.count())),
    Err(Error { status: Status::Contended, .. }) => println!("the arena serves another call"),
    Err(error) => println!("{}: {}", error.status, error.message),
}

Status carries the C enumerators’ values and leaves success to Result, so an Error never carries Status::Deferred, which only Deferred::status reports. Status, Scalar, Mood, CPUClass, GPUClass, Modality, Objective and Negatives print through Display and parse through FromStr the names the C tables own, such as "shape-mismatch" or "intel-haswell", and MultimemTier prints its own, which C never reads back. A panic inside a progress handler is caught at the C frame, since unwinding out of one is an abort, and resurfaces once the call is final.

API

Types

ResultThe result of every fallible call in this crate.
lib.rs:586 ↗
pub type Result<Value> = Result<Value, Error>;
StructErrorA failure, whether the library reported it or the binding caught it before the call.
types.rs:572 ↗
pub struct Error

Messages are static storage, so nothing allocates on the failure path.

Mirrors a failed uform_outcome_t.

Fields

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

Implements

Clone, Copy, StructuralPartialEq, PartialEq, Eq, Debug, Display, Error
EnumStatusEvery value the C status word takes besides success, numbered alike.
types.rs:489 ↗
pub enum Status

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

Mirrors uform_status_t.

Values

Deferred1The call was submitted deferred and is not final yet.
OutOfMemory2Device, pinned, or host memory could not be allocated, or the executor's scratch ceiling is too low.
ShapeMismatch3Item counts, a pixel shape, or a batch envelope disagree with the call or the model.
UnsupportedLayout4A stride or packing the model cannot read.
UnknownKind5A scalar, modality, or name this build does not know.
Io7A checkpoint file could not be opened, read, or written.
Device8The driver refused or the device faulted; after a fault the executor refuses every later call.
Malformed9Supplied bytes could not be decoded: a checkpoint, an image, a clip, or a recording.
Internal10The library reported neither success nor a failure.
ConfigMismatch13The request contradicts a frozen configuration, like resuming a checkpoint of another geometry.
Contended14The call was refused rather than waited for, like a submission to a full deferred table.
Cancelled15A progress handler stopped the call; it unwound and published nothing.
Unsupported16The verb is declared for every residency or model, but this one does not implement it.
InvalidArgument17An argument breaks the verb's contract.

Implements

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