diff --git a/src/coreaudio/mod.rs b/src/coreaudio/mod.rs index ed6c32d..11e2861 100644 --- a/src/coreaudio/mod.rs +++ b/src/coreaudio/mod.rs @@ -15,6 +15,7 @@ use UnknownTypeInputBuffer; use UnknownTypeOutputBuffer; use std::ffi::CStr; +use std::fmt; use std::mem; use std::os::raw::c_char; use std::ptr::null; @@ -302,6 +303,15 @@ impl Device { } } +impl fmt::Debug for Device { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Device") + .field("audio_device_id", &self.audio_device_id) + .field("name", &self.name()) + .finish() + } +} + // The ID of a stream is its index within the `streams` array of the events loop. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct StreamId(usize); diff --git a/src/lib.rs b/src/lib.rs index e7f8e8b..2303819 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -395,6 +395,12 @@ impl Device { } } +impl fmt::Debug for Device { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.0, f) + } +} + impl EventLoop { /// Initializes a new events loop. #[inline] diff --git a/src/wasapi/device.rs b/src/wasapi/device.rs index 0ef90eb..7331381 100644 --- a/src/wasapi/device.rs +++ b/src/wasapi/device.rs @@ -1,5 +1,6 @@ use std; use std::ffi::OsString; +use std::fmt; use std::io::Error as IoError; use std::mem; use std::ops::{Deref, DerefMut}; @@ -552,6 +553,15 @@ impl Clone for Device { } } +impl fmt::Debug for Device { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Device") + .field("device", &self.device) + .field("name", &self.name()) + .finish() + } +} + impl Drop for Device { #[inline] fn drop(&mut self) {