From 9ff39bae6f19e9df137e29bbf742c0d370267e38 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 30 Nov 2020 20:32:52 +0100 Subject: [PATCH] audio,video: Use autogenerated Display impl --- examples/src/bin/pad_probes.rs | 2 +- gstreamer-audio/src/audio_format.rs | 7 ------- gstreamer-video/src/video_format.rs | 7 ------- gstreamer-video/src/video_info.rs | 27 +++------------------------ 4 files changed, 4 insertions(+), 39 deletions(-) diff --git a/examples/src/bin/pad_probes.rs b/examples/src/bin/pad_probes.rs index fccd04b31..e067f343a 100644 --- a/examples/src/bin/pad_probes.rs +++ b/examples/src/bin/pad_probes.rs @@ -24,7 +24,7 @@ fn example_main() { // from the resulting pipeline. let pipeline = gst::parse_launch(&format!( "audiotestsrc name=src ! audio/x-raw,format={},channels=1 ! fakesink", - gst_audio::AUDIO_FORMAT_S16.to_str() + gst_audio::AUDIO_FORMAT_S16 )) .unwrap(); let pipeline = pipeline.dynamic_cast::().unwrap(); diff --git a/gstreamer-audio/src/audio_format.rs b/gstreamer-audio/src/audio_format.rs index 3cbb83b54..30642c5a8 100644 --- a/gstreamer-audio/src/audio_format.rs +++ b/gstreamer-audio/src/audio_format.rs @@ -7,7 +7,6 @@ // except according to those terms. use std::ffi::CStr; -use std::fmt; use std::str; use glib::translate::{from_glib, FromGlib, ToGlib, ToGlibPtr}; @@ -154,12 +153,6 @@ impl str::FromStr for crate::AudioFormat { } } -impl fmt::Display for crate::AudioFormat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str((*self).to_str()) - } -} - impl PartialOrd for crate::AudioFormat { fn partial_cmp(&self, other: &crate::AudioFormat) -> Option { crate::AudioFormatInfo::from_format(*self) diff --git a/gstreamer-video/src/video_format.rs b/gstreamer-video/src/video_format.rs index 81ae11ba1..82cf399a0 100644 --- a/gstreamer-video/src/video_format.rs +++ b/gstreamer-video/src/video_format.rs @@ -8,7 +8,6 @@ use once_cell::sync::Lazy; use std::ffi::CStr; -use std::fmt; use std::str; use glib::translate::{from_glib, FromGlib, ToGlib, ToGlibPtr}; @@ -350,12 +349,6 @@ impl str::FromStr for crate::VideoFormat { } } -impl fmt::Display for crate::VideoFormat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str((*self).to_str()) - } -} - impl PartialOrd for crate::VideoFormat { fn partial_cmp(&self, other: &crate::VideoFormat) -> Option { crate::VideoFormatInfo::from_format(*self) diff --git a/gstreamer-video/src/video_info.rs b/gstreamer-video/src/video_info.rs index 327400425..d90257104 100644 --- a/gstreamer-video/src/video_info.rs +++ b/gstreamer-video/src/video_info.rs @@ -12,7 +12,10 @@ use glib::translate::{ }; use gst::prelude::*; +#[cfg(any(feature = "v1_12", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))] use std::ffi::CStr; + use std::fmt; use std::mem; use std::ptr; @@ -956,24 +959,6 @@ impl str::FromStr for crate::VideoFieldOrder { } } -#[cfg(any(feature = "v1_12", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))] -impl fmt::Display for crate::VideoFieldOrder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str((*self).to_str()) - } -} - -impl crate::VideoInterlaceMode { - pub fn to_str<'a>(self) -> &'a str { - unsafe { - CStr::from_ptr(ffi::gst_video_interlace_mode_to_string(self.to_glib())) - .to_str() - .unwrap() - } - } -} - impl str::FromStr for crate::VideoInterlaceMode { type Err = glib::error::BoolError; @@ -988,12 +973,6 @@ impl str::FromStr for crate::VideoInterlaceMode { } } -impl fmt::Display for crate::VideoInterlaceMode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str((*self).to_str()) - } -} - #[cfg(test)] mod tests { use super::*;