From d0ff4fe91fa15a406340114f89f0a7cfd880a0f0 Mon Sep 17 00:00:00 2001 From: Dickless <37750743+Dicklessgreat@users.noreply.github.com> Date: Fri, 21 Jul 2023 04:53:45 +0900 Subject: [PATCH] Fix warnings in asio_sys (#779) * Fixed warnings using deprecated Error::description * Allowed dead_code --- asio-sys/src/bindings/errors.rs | 49 ++++++++++++--------------------- src/host/asio/stream.rs | 1 + 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/asio-sys/src/bindings/errors.rs b/asio-sys/src/bindings/errors.rs index aa78fd2..3cf1517 100644 --- a/asio-sys/src/bindings/errors.rs +++ b/asio-sys/src/bindings/errors.rs @@ -39,7 +39,21 @@ pub enum AsioErrorWrapper { impl fmt::Display for LoadDriverError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.description()) + match *self { + LoadDriverError::LoadDriverFailed => { + write!( + f, + "{}", + "ASIO `loadDriver` function returned `false` indicating failure" + ) + } + LoadDriverError::InitializationFailed(ref err) => { + write!(f, "{}", err) + } + LoadDriverError::DriverAlreadyExists => { + write!(f, "{}", "ASIO only supports loading one driver at a time") + } + } } } @@ -70,37 +84,8 @@ impl fmt::Display for AsioError { } } -impl Error for LoadDriverError { - fn description(&self) -> &str { - match *self { - LoadDriverError::LoadDriverFailed => { - "ASIO `loadDriver` function returned `false` indicating failure" - } - LoadDriverError::InitializationFailed(ref err) => err.description(), - LoadDriverError::DriverAlreadyExists => { - "ASIO only supports loading one driver at a time" - } - } - } -} - -impl Error for AsioError { - fn description(&self) -> &str { - match *self { - AsioError::NoDrivers => "hardware input or output is not present or available", - AsioError::HardwareMalfunction => { - "hardware is malfunctioning (can be returned by any ASIO function)" - } - AsioError::InvalidInput => "input parameter invalid", - AsioError::BadMode => "hardware is in a bad mode or used in a bad mode", - AsioError::HardwareStuck => "hardware is not running when sample position is inquired", - AsioError::NoRate => "sample clock or rate cannot be determined or is not present", - AsioError::ASE_NoMemory => "not enough memory for completing the request", - AsioError::InvalidBufferSize => "buffersize out of range for device", - AsioError::UnknownError => "Error not in SDK", - } - } -} +impl Error for LoadDriverError {} +impl Error for AsioError {} impl From for LoadDriverError { fn from(err: AsioError) -> Self { diff --git a/src/host/asio/stream.rs b/src/host/asio/stream.rs index a68b937..a0dfe83 100644 --- a/src/host/asio/stream.rs +++ b/src/host/asio/stream.rs @@ -26,6 +26,7 @@ pub struct Stream { playing: Arc, // Ensure the `Driver` does not terminate until the last stream is dropped. driver: Arc, + #[allow(dead_code)] asio_streams: Arc>, callback_id: sys::CallbackId, }