Change SupportedFormatsError::Unknown variant to BackendSpecific
This allows for also passing through a description of the unknown/platform-specific error.
This commit is contained in:
parent
42fc702f53
commit
78a7cb9e79
4 changed files with 106 additions and 43 deletions
19
src/lib.rs
19
src/lib.rs
|
|
@ -300,9 +300,7 @@ pub struct BackendSpecificError {
|
|||
/// An error that might occur while attempting to enumerate the available devices on a system.
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum DevicesError {
|
||||
/// Some error that is specific to the backend from which it was produced.
|
||||
///
|
||||
/// Note: This error is often used when
|
||||
/// See the `BackendSpecificError` docs for more information about this error variant.
|
||||
#[fail(display = "{}", err)]
|
||||
BackendSpecific {
|
||||
#[fail(cause)]
|
||||
|
|
@ -320,9 +318,12 @@ pub enum SupportedFormatsError {
|
|||
/// We called something the C-Layer did not understand
|
||||
#[fail(display = "Invalid argument passed to the backend. For example, this happens when trying to read capture capabilities when the device does not support it.")]
|
||||
InvalidArgument,
|
||||
/// The C-Layer returned an error we don't know about
|
||||
#[fail(display = "An unknown error in the backend occured.")]
|
||||
Unknown
|
||||
/// See the `BackendSpecificError` docs for more information about this error variant.
|
||||
#[fail(display = "{}", err)]
|
||||
BackendSpecific {
|
||||
#[fail(cause)]
|
||||
err: BackendSpecificError,
|
||||
}
|
||||
}
|
||||
|
||||
/// May occur when attempting to request the default input or output stream format from a `Device`.
|
||||
|
|
@ -741,6 +742,12 @@ impl From<BackendSpecificError> for DevicesError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<BackendSpecificError> for SupportedFormatsError {
|
||||
fn from(err: BackendSpecificError) -> Self {
|
||||
SupportedFormatsError::BackendSpecific { err }
|
||||
}
|
||||
}
|
||||
|
||||
// If a backend does not provide an API for retrieving supported formats, we query it with a bunch
|
||||
// of commonly used rates. This is always the case for wasapi and is sometimes the case for alsa.
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue