pub enum Error {
WouldBlock,
Stopped,
Disconnected(String),
PermissionDenied(String),
InvalidConfig(String),
Backend(Box<dyn StdError + Send + Sync>),
}Expand description
Streaming-specific error type.
This error type is designed for the streaming API and includes variants that enforce the uniform backpressure contract across all backends.
Variants§
WouldBlock
The device/library cannot accept more data right now.
Stopped
The stream was explicitly stopped via StreamControl::stop().
Disconnected(String)
The device disconnected or became unreachable.
PermissionDenied(String)
The OS denied access to the device (e.g. a USB permission failure).
Distinct from Error::Backend so consumers can detect a fixable
setup problem — on Linux a USB laser DAC needs a udev rule granting the
user access to the device node — and guide the user rather than surface
a generic error. Retriable: once access is granted (udev rule installed
and the device replugged/re-triggered) a later connect attempt succeeds.
InvalidConfig(String)
Invalid configuration or API misuse.
Backend(Box<dyn StdError + Send + Sync>)
Backend/protocol error (wrapped).
Implementations§
Source§impl Error
impl Error
Sourcepub fn disconnected(msg: impl Into<String>) -> Self
pub fn disconnected(msg: impl Into<String>) -> Self
Create a disconnected error with a message.
Sourcepub fn permission_denied(msg: impl Into<String>) -> Self
pub fn permission_denied(msg: impl Into<String>) -> Self
Create a permission-denied error with a message.
Sourcepub fn usb_permission_denied(context: impl Display) -> Self
pub fn usb_permission_denied(context: impl Display) -> Self
Create a permission-denied error for a USB access failure, appending a platform-appropriate hint. On Linux, USB laser DACs are inaccessible to non-root users until a udev rule grants access to the device node, so the message points at that fix; other platforms get the bare context.
Sourcepub fn invalid_config(msg: impl Into<String>) -> Self
pub fn invalid_config(msg: impl Into<String>) -> Self
Create an invalid config error with a message.
Sourcepub fn backend(err: impl StdError + Send + Sync + 'static) -> Self
pub fn backend(err: impl StdError + Send + Sync + 'static) -> Self
Create a backend error from any error type.
Sourcepub fn is_would_block(&self) -> bool
pub fn is_would_block(&self) -> bool
Returns true if this is a WouldBlock error.
Sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true if this is a Disconnected error.
Sourcepub fn is_permission_denied(&self) -> bool
pub fn is_permission_denied(&self) -> bool
Returns true if this is a PermissionDenied error.
Consumers can branch on this to guide the user through granting device access (e.g. installing a udev rule on Linux) instead of showing a generic failure.
Sourcepub fn is_stopped(&self) -> bool
pub fn is_stopped(&self) -> bool
Returns true if this is a Stopped error.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()