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/1274>
This commit is contained in:
Sebastian Dröge 2023-06-06 14:09:48 +03:00
parent 24a00b9929
commit af77bd0b6a
2 changed files with 14 additions and 5 deletions

View file

@ -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<O: IsA<DiscovererStreamInfo>> 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 {}

View file

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