pbutils: Move DiscovererStreamInfo iterators to an extension trait

This way it can also be called directly on subclasses.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1273>
This commit is contained in:
Sebastian Dröge 2023-06-06 14:09:48 +03:00
parent 2becc79dfb
commit b89b135c93
2 changed files with 11 additions and 5 deletions

View file

@ -28,20 +28,25 @@ impl Iterator for Iter {
} }
} }
impl DiscovererStreamInfo { impl std::iter::FusedIterator for Iter {}
pub fn next_iter(&self) -> Iter {
pub trait DiscovererStreamInfoExtManual: 'static {
fn next_iter(&self) -> Iter;
fn previous_iter(&self) -> Iter;
}
impl<O: IsA<DiscovererStreamInfo>> DiscovererStreamInfoExtManual for O {
fn next_iter(&self) -> Iter {
Iter { Iter {
stream_info: self.next(), stream_info: self.next(),
direction_forward: true, direction_forward: true,
} }
} }
pub fn previous_iter(&self) -> Iter { fn previous_iter(&self) -> Iter {
Iter { Iter {
stream_info: self.previous(), stream_info: self.previous(),
direction_forward: false, direction_forward: false,
} }
} }
} }
impl std::iter::FusedIterator for Iter {}

View file

@ -62,6 +62,7 @@ pub mod prelude {
pub use crate::{ pub use crate::{
audio_visualizer::*, audio_visualizer::*,
auto::traits::*, auto::traits::*,
discoverer_stream_info::DiscovererStreamInfoExtManual,
encoding_profile::{ encoding_profile::{
EncodingProfileBuilder, EncodingProfileExtManual, EncodingProfileHasRestrictionGetter, EncodingProfileBuilder, EncodingProfileExtManual, EncodingProfileHasRestrictionGetter,
}, },