From 5423d7c93a677acd7252c80775c022a766381bd6 Mon Sep 17 00:00:00 2001 From: Mike English Date: Mon, 28 Aug 2023 15:14:15 -0400 Subject: [PATCH] Add more detailed Debug for MapSource (#56) and everything it contains. Stop short of printing all of the bytes in a State's VecDeque, but expose most everything else for easier troubleshooting. --- moq-warp/src/model/segment.rs | 2 +- moq-warp/src/model/track.rs | 8 +------- moq-warp/src/model/watch.rs | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/moq-warp/src/model/segment.rs b/moq-warp/src/model/segment.rs index 5cac4e3..5726e39 100644 --- a/moq-warp/src/model/segment.rs +++ b/moq-warp/src/model/segment.rs @@ -49,7 +49,7 @@ impl Deref for Publisher { } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Subscriber { pub info: Arc, diff --git a/moq-warp/src/model/track.rs b/moq-warp/src/model/track.rs index 4cc38ce..0704c72 100644 --- a/moq-warp/src/model/track.rs +++ b/moq-warp/src/model/track.rs @@ -51,7 +51,7 @@ impl fmt::Debug for Publisher { } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Subscriber { pub name: String, @@ -72,12 +72,6 @@ impl Subscriber { } } -impl fmt::Debug for Subscriber { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "track subscriber: {:?}", self.name) - } -} - #[derive(Clone)] pub struct Error { pub code: VarInt, diff --git a/moq-warp/src/model/watch.rs b/moq-warp/src/model/watch.rs index 8c64576..3ae16df 100644 --- a/moq-warp/src/model/watch.rs +++ b/moq-warp/src/model/watch.rs @@ -1,3 +1,4 @@ +use core::fmt; use std::collections::VecDeque; use tokio::sync::watch; @@ -7,6 +8,18 @@ struct State { drained: usize, } +impl fmt::Debug for State { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!( + f, + "State<{}> ( queue.len(): {}, drained: {} )", + std::any::type_name::(), + &self.queue.len(), + &self.drained + ) + } +} + impl State { fn new() -> Self { Self { @@ -85,7 +98,7 @@ impl Default for Publisher { } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Subscriber { state: watch::Receiver>, index: usize,