#[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
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
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].
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].
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
OrtLoadFailed
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.
OrtSessionBuildFailed(Box<dyn Error + Sync + Send>)
OrtThreadsConfigFailed(Box<dyn Error + Sync + Send>)
VadModelLoadFailed
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].
OrtInferenceFailed(Box<dyn Error + Sync + Send>)
OrtTensorCreateFailed
OrtTensorExtractFailed
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.
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.
Implementations§
Source§impl DecibriError
impl DecibriError
Sourcepub fn is_ort_path_error(&self) -> bool
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::OrtLoadFailedfires when ORT tried to load the path and failed (e.g. wrong ORT version, corrupted dylib).Self::OrtPathInvalidfires 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
impl Debug for DecibriError
Source§impl Display for DecibriError
impl Display for DecibriError
Source§impl Error for DecibriError
impl Error for DecibriError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ResamplerError> for DecibriError
Available on crate feature capture only.Bridge the capture resampler’s construction error into the central error.
impl From<ResamplerError> for DecibriError
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.