From af77bd0b6a37a4d9e19e5eac72903be4262ae2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 6 Jun 2023 14:09:48 +0300 Subject: [PATCH] pbutils: Move `DiscovererStreamInfo` iterators to an extension trait This way it can also be called directly on subclasses. Part-of: --- .../src/discoverer_stream_info.rs | 18 +++++++++++++----- gstreamer-pbutils/src/lib.rs | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gstreamer-pbutils/src/discoverer_stream_info.rs b/gstreamer-pbutils/src/discoverer_stream_info.rs index 756e35725..180343c39 100644 --- a/gstreamer-pbutils/src/discoverer_stream_info.rs +++ b/gstreamer-pbutils/src/discoverer_stream_info.rs @@ -30,15 +30,25 @@ impl Iterator for Iter { } } -impl DiscovererStreamInfo { - pub fn next_iter(&self) -> Iter { +impl std::iter::FusedIterator for Iter {} + +pub trait DiscovererStreamInfoExtManual: 'static { + fn next_iter(&self) -> Iter; + fn previous_iter(&self) -> Iter; + #[doc(alias = "gst_discoverer_stream_info_get_stream_id")] + #[doc(alias = "get_stream_id")] + fn stream_id(&self) -> glib::GString; +} + +impl> DiscovererStreamInfoExtManual for O { + fn next_iter(&self) -> Iter { Iter { stream_info: self.next(), direction_forward: true, } } - pub fn previous_iter(&self) -> Iter { + fn previous_iter(&self) -> Iter { Iter { stream_info: self.previous(), direction_forward: false, @@ -57,5 +67,3 @@ impl DiscovererStreamInfo { } } } - -impl std::iter::FusedIterator for Iter {} diff --git a/gstreamer-pbutils/src/lib.rs b/gstreamer-pbutils/src/lib.rs index 466ebf7de..fd9ef17bf 100644 --- a/gstreamer-pbutils/src/lib.rs +++ b/gstreamer-pbutils/src/lib.rs @@ -62,6 +62,7 @@ pub mod prelude { pub use crate::{ audio_visualizer::*, auto::traits::*, + discoverer_stream_info::DiscovererStreamInfoExtManual, encoding_profile::{ EncodingProfileBuilder, EncodingProfileExtManual, EncodingProfileHasRestrictionGetter, },