From b89b135c935c568f255d6f49991b6235b0d7381c 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: --- gstreamer-pbutils/src/discoverer_stream_info.rs | 15 ++++++++++----- gstreamer-pbutils/src/lib.rs | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gstreamer-pbutils/src/discoverer_stream_info.rs b/gstreamer-pbutils/src/discoverer_stream_info.rs index 8f83fa3ba..7d0cb9939 100644 --- a/gstreamer-pbutils/src/discoverer_stream_info.rs +++ b/gstreamer-pbutils/src/discoverer_stream_info.rs @@ -28,20 +28,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; +} + +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, } } } - -impl std::iter::FusedIterator for Iter {} diff --git a/gstreamer-pbutils/src/lib.rs b/gstreamer-pbutils/src/lib.rs index 1aedd6a24..5a64094e7 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, },