Skip to main content

forge_capture/
error.rs

1//! Why a microphone could not be opened or used.
2
3/// What a host could not do with the microphone.
4#[derive(Debug, Clone, thiserror::Error)]
5pub enum Error {
6    /// The host has no default input device at all.
7    #[error("no input device is available")]
8    NoInputDevice,
9    /// A named device is not present. The alternatives are listed because
10    /// a person who picked an interface needs the answer to "what is there".
11    #[error("no input device named \"{wanted}\" (available: {available})")]
12    DeviceNotFound {
13        /// The id the caller asked for.
14        wanted: String,
15        /// The devices that are present, as `id (name)` pairs.
16        available: String,
17    },
18    /// The device offers no stream in a format this crate can open.
19    ///
20    /// The sentence leads with the FORMATS and names the rate second: an
21    /// I16-only device refused by a rate sentence sent a reader after a
22    /// sample-rate problem that was never there (#2362).
23    #[error(
24        "the input device offers no F32 or I16 stream for {wanted} Hz input (it offers: {offered})"
25    )]
26    UnsupportedInput {
27        /// The rate the caller needed.
28        wanted: u32,
29        /// What the device offered, so the mismatch is legible.
30        offered: String,
31    },
32    /// The stream could not be opened, configured or started.
33    #[error("{message}")]
34    Capture {
35        /// The host's own words for the failure.
36        message: String,
37    },
38}