mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 03:21:03 +00:00
gstreamer/clock_time: Format Debug like Display
This allows us to drop `.to_string()` from the custom Debug implementations, which now also no longer print as strings.
This commit is contained in:
parent
14edcf9aaf
commit
c05d2e24af
5 changed files with 27 additions and 16 deletions
|
@ -941,9 +941,9 @@ impl fmt::Debug for BufferRef {
|
|||
|
||||
f.debug_struct("Buffer")
|
||||
.field("ptr", unsafe { &self.as_ptr() })
|
||||
.field("pts", &self.pts().display().to_string())
|
||||
.field("dts", &self.dts().display().to_string())
|
||||
.field("duration", &self.duration().display().to_string())
|
||||
.field("pts", &self.pts().display())
|
||||
.field("dts", &self.dts().display())
|
||||
.field("duration", &self.duration().display())
|
||||
.field("size", &self.size())
|
||||
.field("offset", &self.offset())
|
||||
.field("offset_end", &self.offset_end())
|
||||
|
|
|
@ -197,8 +197,8 @@ impl fmt::Debug for BufferListRef {
|
|||
f.debug_struct("BufferList")
|
||||
.field("ptr", unsafe { &self.as_ptr() })
|
||||
.field("buffers", &self.len())
|
||||
.field("pts", &pts.display().to_string())
|
||||
.field("dts", &dts.display().to_string())
|
||||
.field("pts", &pts.display())
|
||||
.field("dts", &dts.display())
|
||||
.field("size", &size)
|
||||
.finish()
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::io::{self, prelude::*};
|
|||
use std::time::Duration;
|
||||
use std::{cmp, convert, fmt, str};
|
||||
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Debug, Default)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Default)]
|
||||
pub struct ClockTime(pub(crate) u64);
|
||||
|
||||
impl ClockTime {
|
||||
|
@ -419,7 +419,12 @@ impl fmt::Display for ClockTime {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
impl fmt::Debug for ClockTime {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DisplayableOptClockTime(Option<ClockTime>);
|
||||
|
||||
impl fmt::Display for DisplayableOptClockTime {
|
||||
|
@ -428,6 +433,12 @@ impl fmt::Display for DisplayableOptClockTime {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for DisplayableOptClockTime {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::utils::Displayable for Option<ClockTime> {
|
||||
type DisplayImpl = DisplayableOptClockTime;
|
||||
|
||||
|
|
|
@ -503,8 +503,8 @@ impl fmt::Debug for ReferenceTimestampMeta {
|
|||
|
||||
f.debug_struct("ReferenceTimestampMeta")
|
||||
.field("reference", &self.reference())
|
||||
.field("timestamp", &self.timestamp().display().to_string())
|
||||
.field("duration", &self.duration().display().to_string())
|
||||
.field("timestamp", &self.timestamp().display())
|
||||
.field("duration", &self.duration().display())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -591,16 +591,16 @@ impl<T: FormattedValueIntrinsic> fmt::Debug for FormattedSegment<T> {
|
|||
let segment = segment.downcast_ref::<crate::ClockTime>().unwrap();
|
||||
f.debug_struct("Segment")
|
||||
.field("format", &Format::Time)
|
||||
.field("start", &segment.start().display().to_string())
|
||||
.field("offset", &segment.offset().display().to_string())
|
||||
.field("stop", &segment.stop().display().to_string())
|
||||
.field("start", &segment.start().display())
|
||||
.field("offset", &segment.offset().display())
|
||||
.field("stop", &segment.stop().display())
|
||||
.field("rate", &segment.rate())
|
||||
.field("applied_rate", &segment.applied_rate())
|
||||
.field("flags", &segment.flags())
|
||||
.field("time", &segment.time().display().to_string())
|
||||
.field("base", &segment.base().display().to_string())
|
||||
.field("position", &segment.position().display().to_string())
|
||||
.field("duration", &segment.duration().display().to_string())
|
||||
.field("time", &segment.time().display())
|
||||
.field("base", &segment.base().display())
|
||||
.field("position", &segment.position().display())
|
||||
.field("duration", &segment.duration().display())
|
||||
.finish()
|
||||
}
|
||||
_ => f
|
||||
|
|
Loading…
Reference in a new issue