Skip to main content

DecibriError

Enum DecibriError 

Source
#[non_exhaustive]
pub enum DecibriError {
Show 37 variants SampleRateOutOfRange, ChannelsOutOfRange, MultichannelNotSupported, FramesPerBufferOutOfRange, AgcTargetOutOfRange, LimiterCeilingOutOfRange, InvalidFormat, MicrophoneNotFound(String), SpeakerNotFound(String), MultipleDevicesMatch { name: String, matches: String, }, DeviceIndexOutOfRange, NoMicrophoneFound, NoSpeakerFound, NotAnInputDevice, DeviceEnumerationFailed(String), AlreadyRunning, StreamOpenFailed(String), StreamStartFailed(String), PermissionDenied, MicrophoneStreamClosed, SpeakerStreamClosed, DeviceFailed { source: Box<dyn Error + Sync + Send>, }, ResampleConfigInvalid { in_rate: u32, out_rate: u32, }, VadSampleRateUnsupported(u32), VadThresholdOutOfRange(f32), OrtInitFailed { source: Box<dyn Error + Sync + Send>, }, OrtLoadFailed { path: PathBuf, source: Box<dyn Error + Sync + Send>, }, OrtPathInvalid { path: PathBuf, reason: &'static str, }, OrtSessionBuildFailed(Box<dyn Error + Sync + Send>), OrtThreadsConfigFailed(Box<dyn Error + Sync + Send>), VadModelLoadFailed { path: PathBuf, source: Box<dyn Error + Sync + Send>, }, ModelLoadFailed { path: PathBuf, source: Box<dyn Error + Sync + Send>, }, OrtInferenceFailed(Box<dyn Error + Sync + Send>), OrtTensorCreateFailed { kind: &'static str, source: Box<dyn Error + Sync + Send>, }, OrtTensorExtractFailed { kind: &'static str, source: Box<dyn Error + Sync + Send>, }, ForkAfterOrtInit { init_pid: u32, current_pid: u32, }, OnnxBackendFailed { backend: &'static str, source: Box<dyn Error + Sync + Send>, },
}
Expand description

Errors produced by decibri operations.

This enum is #[non_exhaustive]: consumers pattern-matching on it must include a _ => catch-all arm so future variant additions are not source-breaking.

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.
§

SampleRateOutOfRange

§

ChannelsOutOfRange

§

MultichannelNotSupported

A microphone capture configuration requested more than one channel.

Microphone capture is mono only: crate::microphone::MicrophoneConfig::validate rejects channels > 1 rather than silently downmixing it to mono. The channels field is retained, so honouring channels > 1 later (by delivering true interleaved multichannel) stays an additive change: the accepted set widens from {1} outward, breaking no caller. A dedicated variant rather than reusing Self::ChannelsOutOfRange reads more intentionally and signals the mono-only constraint explicitly; a zero channel count remains Self::ChannelsOutOfRange. The speaker path is unaffected (output may be multichannel) and keeps using Self::ChannelsOutOfRange for its 1..=32 range. Static message to keep the text stable.

§

FramesPerBufferOutOfRange

§

AgcTargetOutOfRange

The agc target level fell outside the supported dBFS range.

agc is Option<i8> on crate::microphone::MicrophoneConfig, so a representably-invalid target (a value outside -40..=-3) can reach the core directly from a Rust consumer that bypasses the bindings. This is the load-bearing backstop: crate::microphone::MicrophoneConfig::validate returns it rather than clamping, matching how sample_rate is range checked. Static message to keep the text stable.

§

LimiterCeilingOutOfRange

The limiter ceiling fell outside the supported dBFS range.

limiter is Option<f32> on crate::microphone::MicrophoneConfig, so a representably-invalid ceiling (a value outside -3.0..=0.0) can reach the core directly from a Rust consumer that bypasses the bindings. This is the load-bearing backstop: crate::microphone::MicrophoneConfig::validate returns it rather than clamping, matching how agc is range checked. A distinct variant from Self::AgcTargetOutOfRange because the parameter, range, and message differ. Static message to keep the text stable.

§

InvalidFormat

§

MicrophoneNotFound(String)

§

SpeakerNotFound(String)

No output device matched a Name or Id selector.

Distinct from Self::MicrophoneNotFound so the display message names the speaker when the lookup was against output devices. Issued when a Name or Id selector matches no output device.

§

MultipleDevicesMatch

Fields

§name: String
§matches: String
§

DeviceIndexOutOfRange

§

NoMicrophoneFound

§

NoSpeakerFound

§

NotAnInputDevice

§

DeviceEnumerationFailed(String)

§

AlreadyRunning

§

StreamOpenFailed(String)

§

StreamStartFailed(String)

§

PermissionDenied

§

MicrophoneStreamClosed

Microphone stream has closed (stopped explicitly or by driver error). Returned from MicrophoneStream::try_next_chunk / next_chunk when the underlying channel has disconnected.

§

SpeakerStreamClosed

Speaker stream has closed. Returned from SpeakerStream::send when the underlying channel has disconnected.

§

DeviceFailed

An active audio stream failed at the device or driver level while running (device unplugged, driver reset, exclusive-mode preemption).

Distinct from Self::StreamOpenFailed / Self::StreamStartFailed, which fire at open/start time: this is reported by the cpal error callback during streaming. The underlying cpal::StreamError is carried boxed as a #[source] (the same pattern as Self::OnnxBackendFailed), so a consumer can walk error.source() (and downcast to cpal::StreamError) to distinguish a cause such as device-not-available from a backend-specific driver error, with no cpal type appearing in this enum’s public signature. After it fires the stream is treated as closed; a consumer that sees MicrophoneStreamClosed / SpeakerStreamClosed can call take_last_error() on the stream to retrieve this cause. Additive variant permitted by #[non_exhaustive].

Fields

§source: Box<dyn Error + Sync + Send>
§

ResampleConfigInvalid

The capture resampler could not be constructed for the negotiated device-native to requested-target sample rate conversion.

The payload carries the offending rates for programmatic inspection; they are not formatted into the Display string, so the message text stays stable (matching Self::VadSampleRateUnsupported). Unreachable for a configured rate in the validated 1000..=384000 range over any device-native rate (every such pair is far below the resampler’s filter cap); surfaced defensively. Additive variant permitted by #[non_exhaustive].

Fields

§in_rate: u32
§out_rate: u32
§

VadSampleRateUnsupported(u32)

Payload carries the offending sample rate; not formatted into the Display string to keep the message text stable.

§

VadThresholdOutOfRange(f32)

Payload carries the offending threshold; not formatted into the Display string to keep the message text stable.

§

OrtInitFailed

Fields

§source: Box<dyn Error + Sync + Send>
§

OrtLoadFailed

Fields

§path: PathBuf
§source: Box<dyn Error + Sync + Send>
§

OrtPathInvalid

The ort_library_path in VadConfig failed a pre-check before it could be handed to ort::init_from. Used only by the Windows hang-prevention pre-check in init_ort_once.

Intentionally does not carry an ort::Error source, because constructing an ort::Error under ort-load-dynamic calls into the ORT C API (ortsys![CreateStatus]), which is exactly the hang this pre-check is designed to prevent. Keeping this variant string-only means the pre-check never touches ORT symbols.

Display message matches Self::OrtLoadFailed so Node, Python, and future FFI consumers see the same actionable hint regardless of which failure path was taken.

Fields

§path: PathBuf
§reason: &'static str
§

OrtSessionBuildFailed(Box<dyn Error + Sync + Send>)

§

OrtThreadsConfigFailed(Box<dyn Error + Sync + Send>)

§

VadModelLoadFailed

Fields

§path: PathBuf
§source: Box<dyn Error + Sync + Send>
§

ModelLoadFailed

A bundled model file failed to load through the shared ONNX session seam.

Model-agnostic counterpart to Self::VadModelLoadFailed: the capture denoise stage surfaces this when its model file cannot be opened, so a denoise load failure is not reported as a VAD error. Carries the offending path and the underlying error boxed via #[source], matching the other model-load variants. Additive variant permitted by #[non_exhaustive].

Fields

§path: PathBuf
§source: Box<dyn Error + Sync + Send>
§

OrtInferenceFailed(Box<dyn Error + Sync + Send>)

§

OrtTensorCreateFailed

Fields

§kind: &'static str
§source: Box<dyn Error + Sync + Send>
§

OrtTensorExtractFailed

Fields

§kind: &'static str
§source: Box<dyn Error + Sync + Send>
§

ForkAfterOrtInit

Raised when ONNX Runtime is used in a child process after being initialized in the parent.

Python’s fork start method on Linux duplicates the parent’s memory into the child, but ONNX Runtime’s internal state (allocators, thread pools, model graph state) is not safe to share across forked processes. Without proactive detection, a child that uses Silero VAD inherited via fork would silently produce wrong probabilities, segfault, or hang.

init_pid is the pid that first initialized ORT (typically the parent that loaded Microphone(vad="silero") before fork); current_pid is the pid that called the inference path and triggered the detection.

Remediation is in the user’s hands: switch to spawn start method or construct Microphone(vad="silero") inside the child rather than the parent. The Display message embeds both options.

Fields

§init_pid: u32
§current_pid: u32
§

OnnxBackendFailed

Reserved catch-all for non-ORT ONNX backends.

Not emitted by ORT-backed code paths: ORT failures use the eight preceding variants (OrtSessionBuildFailed, OrtThreadsConfigFailed, VadModelLoadFailed, OrtInferenceFailed, OrtTensorCreateFailed, OrtTensorExtractFailed, plus OrtInitFailed and OrtLoadFailed) which carry the underlying ORT failure boxed via #[source].

Permitted by #[non_exhaustive] on this enum (see line 31). Existing is_ort_path_error returns false on this variant: OnnxBackendFailed is not an ORT path-loading failure.

backend identifies which non-ORT backend produced the error (e.g. "coreml", "tflite"); source carries the backend-native error boxed for trait-object compatibility.

Fields

§backend: &'static str
§source: Box<dyn Error + Sync + Send>

Implementations§

Source§

impl DecibriError

Source

pub fn is_ort_path_error(&self) -> bool

Returns true if this error represents a failure to use a specific ORT library path.

Consumers handling “the ort_library_path is wrong” logic should match on this rather than enumerating Self::OrtLoadFailed and Self::OrtPathInvalid separately:

  • Self::OrtLoadFailed fires when ORT tried to load the path and failed (e.g. wrong ORT version, corrupted dylib).
  • Self::OrtPathInvalid fires when decibri’s filesystem pre-check rejected the path before ORT saw it (nonexistent, directory, etc).

Both represent the same user-facing failure mode: “this path cannot be used to load ORT.” The split is a mechanical necessity (see the rustdoc on Self::OrtPathInvalid), not a categorization users need to care about.

Trait Implementations§

Source§

impl Debug for DecibriError

Source§

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

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

impl Display for DecibriError

Source§

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

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

impl Error for DecibriError

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<ResamplerError> for DecibriError

Available on crate feature capture only.

Bridge the capture resampler’s construction error into the central error.

Both ResamplerError variants are construction-time; the resampler’s steady process path is infallible, so there is no per-chunk error to map. RatePairUnsupported carries the offending rates through; ZeroSampleRate (guarded: the configured target is validated nonzero and the device-native rate is nonzero) and any future variant route to the same error defensively.

Source§

fn from(e: ResamplerError) -> DecibriError

Converts to this type from the input type.

Auto Trait Implementations§

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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 = Infallible

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more