Skip to content

Commit a222c8e

Browse files
committed
Add Debug impl for all public types in context mod
1 parent 7fdea7f commit a222c8e

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

src/context/concrete_base.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ impl PartialEq for ConcreteBaseAudioContext {
6666
}
6767
}
6868

69+
impl std::fmt::Debug for ConcreteBaseAudioContext {
70+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
71+
f.debug_struct("BaseAudioContext")
72+
.field("id", &self.address())
73+
.field("state", &self.state())
74+
.field("sample_rate", &self.sample_rate())
75+
.field("current_time", &self.current_time())
76+
.field("max_channel_count", &self.max_channel_count())
77+
.field("offline", &self.offline())
78+
.finish_non_exhaustive()
79+
}
80+
}
81+
6982
/// Inner representation of the `ConcreteBaseAudioContext`
7083
///
7184
/// These fields are wrapped inside an `Arc` in the actual `ConcreteBaseAudioContext`.

src/context/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
//! The `BaseAudioContext` interface and the `AudioContext` and `OfflineAudioContext` types
2+
3+
#![deny(missing_debug_implementations)]
4+
25
use std::{any::Any, ops::Range};
36

47
mod base;

src/context/offline.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ pub struct OfflineAudioContext {
2929
resume_sender: mpsc::Sender<()>,
3030
}
3131

32+
impl std::fmt::Debug for OfflineAudioContext {
33+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34+
f.debug_struct("OfflineAudioContext")
35+
.field("length", &self.length())
36+
.field("base", &self.base())
37+
.finish_non_exhaustive()
38+
}
39+
}
40+
3241
struct OfflineAudioContextRenderer {
3342
/// the rendering 'thread', fully controlled by the offline context
3443
renderer: RenderThread,

src/context/online.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ pub struct AudioContext {
118118
render_thread_init: RenderThreadInit,
119119
}
120120

121+
impl std::fmt::Debug for AudioContext {
122+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
123+
f.debug_struct("AudioContext")
124+
.field("sink_id", &self.sink_id())
125+
.field("base_latency", &self.base_latency())
126+
.field("output_latency", &self.output_latency())
127+
.field("base", &self.base())
128+
.finish_non_exhaustive()
129+
}
130+
}
131+
121132
impl BaseAudioContext for AudioContext {
122133
fn base(&self) -> &ConcreteBaseAudioContext {
123134
&self.base

0 commit comments

Comments
 (0)