Skip to content

Commit

Permalink
Implement Debug as well as Display.
Browse files Browse the repository at this point in the history
  • Loading branch information
qwandor committed Jul 9, 2024
1 parent ab2615e commit 54911e2
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/device/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use alloc::format;
use alloc::vec;
use alloc::vec::Vec;
use bitflags::bitflags;
use core::fmt::Debug;
use core::{
fmt::{self, Display, Formatter},
hint::spin_loop,
Expand Down Expand Up @@ -1350,6 +1351,19 @@ pub struct VirtIOSndJackInfo {
_padding: [u8; 7],
}

impl Debug for VirtIOSndJackInfo {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.debug_struct("VirtIOSndJackInfo")
.field("hdr", &self.hdr)
.field("features", &JackFeatures::from_bits_retain(self.features))
.field("hda_reg_defconf", &self.hda_reg_defconf)
.field("hda_reg_caps", &self.hda_reg_caps)
.field("connected", &self.connected)
.field("_padding", &self._padding)
.finish()
}
}

impl Display for VirtIOSndJackInfo {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let connected_status = if self.connected == 1 {
Expand Down Expand Up @@ -1459,6 +1473,21 @@ pub struct VirtIOSndPcmInfo {
_padding: [u8; 5],
}

impl Debug for VirtIOSndPcmInfo {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.debug_struct("VirtIOSndPcmInfo")
.field("hdr", &self.hdr)
.field("features", &PcmFeatures::from_bits_retain(self.features))
.field("formats", &PcmFormats::from_bits_retain(self.formats))
.field("rates", &PcmRates::from_bits_retain(self.rates))
.field("direction", &self.direction)
.field("channels_min", &self.channels_min)
.field("channels_max", &self.channels_max)
.field("_padding", &self._padding)
.finish()
}
}

impl Display for VirtIOSndPcmInfo {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let direction = if self.direction == VIRTIO_SND_D_INPUT {
Expand Down

0 comments on commit 54911e2

Please sign in to comment.