Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 15 variants InvalidArgument(String), NotImplemented(String), ModelFileNotFound(String), ModelLoad(String), OutOfMemory(String), Backend(String), Unsupported(String), BadStructSize(String), InputTooLong(String), Aborted { message: String, partial: Option<Box<Transcript>>, }, OutputTruncated { message: String, partial: Option<Box<Transcript>>, }, VersionMismatch(String), Nul(NulError), Busy(String), Other(String),
}
Expand description

Everything that can go wrong talking to the native library.

Match on the variant for typed handling; Error::raw_status recovers the underlying transcribe_status code (0 for errors raised purely on the Rust side, e.g. the load-time version gate or a NUL in a caller string).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InvalidArgument(String)

TRANSCRIBE_ERR_INVALID_ARG (or _SAMPLE_RATE).

§

NotImplemented(String)

TRANSCRIBE_ERR_NOT_IMPLEMENTED — the model has no path for this call.

§

ModelFileNotFound(String)

TRANSCRIBE_ERR_FILE_NOT_FOUND — the GGUF path does not exist.

§

ModelLoad(String)

TRANSCRIBE_ERR_GGUF / _UNSUPPORTED_ARCH / _UNSUPPORTED_VARIANT.

§

OutOfMemory(String)

TRANSCRIBE_ERR_OOM.

§

Backend(String)

TRANSCRIBE_ERR_BACKEND — the requested backend could not be satisfied.

§

Unsupported(String)

TRANSCRIBE_ERR_UNSUPPORTED_{TASK,LANGUAGE,TIMESTAMPS,PNC,ITN} — the model cannot satisfy this request shape.

§

BadStructSize(String)

TRANSCRIBE_ERR_BAD_STRUCT_SIZE — an ABI/struct-size fault. With the generated FFI this indicates a header/library skew, not caller error.

§

InputTooLong(String)

TRANSCRIBE_ERR_INPUT_TOO_LONG — audio longer than the model can decode.

§

Aborted

TRANSCRIBE_ERR_ABORTED — the abort callback returned true. The transcript of chunks that completed before the abort is preserved.

Fields

§message: String
§partial: Option<Box<Transcript>>

Partial transcript from chunks that completed before the abort.

§

OutputTruncated

TRANSCRIBE_ERR_OUTPUT_TRUNCATED — the decode hit the generation budget before end-of-stream; the transcript is incomplete by contract. The partial transcript is always preserved.

Fields

§message: String
§partial: Option<Box<Transcript>>

The (incomplete) transcript produced before truncation.

§

VersionMismatch(String)

The loaded library’s base version disagrees with the headers this crate was generated against (the pre-1.0 version lock). Raised on first use.

§

Nul(NulError)

A caller-supplied string contained an interior NUL byte.

§

Busy(String)

Another session of the same model already has a compute operation in flight. The C library serializes compute per model (the 0.x limitation): at most one run / batch / active stream across ALL of a model’s sessions at a time. Finish or drop the in-flight stream (one-shot runs/batches just queue) before starting another, or give each concurrent worker its own model. Raised purely on the Rust side, so Error::raw_status is 0.

§

Other(String)

A non-OK status with no more specific mapping.

Implementations§

Source§

impl Error

Source

pub fn raw_status(&self) -> i32

The transcribe_status this error was mapped from, or 0 for errors raised on the Rust side (version gate, NUL in a string, …).

Source

pub fn partial(&self) -> Option<&Transcript>

The partial transcript carried by Error::Aborted / Error::OutputTruncated, if any. None for every other variant.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<NulError> for Error

Source§

fn from(source: NulError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.