Skip to content

Commit 7fdea7f

Browse files
committed
Add Debug for MediaElement, enforce lint at node mode
1 parent d75aaf4 commit 7fdea7f

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

src/media_element.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ pub(crate) struct RTSStream {
1919
playback_rate: Arc<AtomicF64>,
2020
}
2121

22+
impl std::fmt::Debug for RTSStream {
23+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24+
f.debug_struct("RTSStream")
25+
.field("number_of_channels", &self.number_of_channels)
26+
.finish_non_exhaustive()
27+
}
28+
}
29+
2230
/// Controller actions for a media element
2331
pub(crate) enum MediaElementAction {
2432
/// Seek to the given timestamp
@@ -46,6 +54,18 @@ pub struct MediaElement {
4654
playback_rate: Arc<AtomicF64>,
4755
}
4856

57+
impl std::fmt::Debug for MediaElement {
58+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
59+
f.debug_struct("MediaElement")
60+
.field("stream", &self.stream)
61+
.field("current_time", &self.current_time())
62+
.field("loop", &self.loop_())
63+
.field("paused", &self.paused())
64+
.field("playback_rate", &self.playback_rate())
65+
.finish_non_exhaustive()
66+
}
67+
}
68+
4969
impl MediaElement {
5070
/// Create a new instance for a given file path
5171
pub fn new<P: Into<PathBuf>>(file: P) -> Result<Self, Box<dyn Error>> {

src/node/media_element_source.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use super::{AudioNode, ChannelConfig, MediaStreamRenderer};
1313
// @note - Does not extend AudioNodeOptions because AudioNodeOptions are
1414
// useless for source nodes as they instruct how to upmix the inputs.
1515
// This is a common source of confusion, see e.g. https://github.com/mdn/content/pull/18472
16+
#[derive(Debug)]
1617
pub struct MediaElementAudioSourceOptions<'a> {
1718
pub media_element: &'a mut MediaElement,
1819
}

src/node/media_stream_source.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use super::{AudioNode, ChannelConfig, MediaStreamRenderer};
1313
// @note - Does not extend AudioNodeOptions because AudioNodeOptions are
1414
// useless for source nodes as they instruct how to upmix the inputs.
1515
// This is a common source of confusion, see e.g. https://github.com/mdn/content/pull/18472
16+
#[derive(Debug)]
1617
pub struct MediaStreamAudioSourceOptions<'a> {
1718
pub media_stream: &'a MediaStream,
1819
}

src/node/media_stream_track_source.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use super::{AudioNode, ChannelConfig, MediaStreamRenderer};
1313
// @note - Does not extend AudioNodeOptions because AudioNodeOptions are
1414
// useless for source nodes as they instruct how to upmix the inputs.
1515
// This is a common source of confusion, see e.g. https://github.com/mdn/content/pull/18472
16+
#[derive(Debug)]
1617
pub struct MediaStreamTrackAudioSourceOptions<'a> {
1718
pub media_stream_track: &'a MediaStreamTrack,
1819
}

src/node/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
//! The AudioNode interface and concrete types
2+
3+
#![deny(missing_debug_implementations)]
4+
25
use std::f32::consts::PI;
36
use std::sync::{Arc, Mutex, OnceLock};
47

0 commit comments

Comments
 (0)