Skip to main content

volumecontrol_core/
error.rs

1use thiserror::Error;
2
3/// Error type for all volumecontrol operations.
4#[derive(Debug, Error)]
5pub enum AudioError {
6    /// The requested device was not found.
7    #[error("audio device not found")]
8    DeviceNotFound,
9
10    /// The audio subsystem could not be initialized.
11    #[error("failed to initialize audio subsystem: {0}")]
12    InitializationFailed(String),
13
14    /// Listing available devices failed.
15    #[error("failed to list audio devices: {0}")]
16    ListFailed(String),
17
18    /// Reading the current volume level failed.
19    #[error("failed to retrieve volume: {0}")]
20    GetVolumeFailed(String),
21
22    /// Changing the volume level failed.
23    #[error("failed to set volume: {0}")]
24    SetVolumeFailed(String),
25
26    /// Reading the mute state failed.
27    #[error("failed to retrieve mute state: {0}")]
28    GetMuteFailed(String),
29
30    /// Changing the mute state failed.
31    #[error("failed to set mute state: {0}")]
32    SetMuteFailed(String),
33
34    /// The operation is not supported on the current platform.
35    #[error("operation not supported on this platform")]
36    Unsupported,
37
38    /// A mutex protecting a platform audio endpoint was poisoned (a thread
39    /// panicked while holding the lock).  The endpoint state may be
40    /// inconsistent; callers should discard the device and re-acquire it.
41    #[error("audio endpoint mutex was poisoned")]
42    EndpointLockPoisoned,
43}