impl Debug for Device (#253)
The internal alsa, null and emscripten Device implementations already
implemented Debug; but the coreaudio and wasapi ones, and therefore
also the wrapper, did not.
I decided to eschew the `Device(…)` wrapping in the outer layer
(hence a custom implementation rather than `#[derive(Debug)]`),
because `Device(Device)`, `Device(Device { … })` and so forth all
look better without the extra `Device(…)` wrapping.
On the wasapi and coreaudio implementations I put both the pointer and
name. Name because it’s useful, pointer because on Windows at least
I believe duplicated names are possible. (e.g. two monitors that include
monitors, of the same type; I haven’t strictly confirmed this, because I
killed those off harshly on my machine and don’t want to reinstate
them.)
I do not have access to a macOS device to confirm that the coreaudio
implementation is sane, but I think it is.
This commit is contained in:
parent
c2d606176a
commit
2679ea845f
3 changed files with 26 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue