mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 09:31:06 +00:00
gstreamer: Implement FromIterator<Caps>
and Extend<Caps>
for Caps
This allows easily generating new/extending existing caps from an iterator. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1151>
This commit is contained in:
parent
774fafd987
commit
56b9b66027
1 changed files with 21 additions and 0 deletions
|
@ -204,6 +204,21 @@ impl std::iter::FromIterator<(Structure, Option<CapsFeatures>)> for Caps {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::iter::FromIterator<Caps> for Caps {
|
||||
fn from_iter<T: IntoIterator<Item = Caps>>(iter: T) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
let mut caps = Caps::new_empty();
|
||||
|
||||
{
|
||||
let caps = caps.get_mut().unwrap();
|
||||
iter.into_iter()
|
||||
.for_each(|other_caps| caps.append(other_caps));
|
||||
}
|
||||
|
||||
caps
|
||||
}
|
||||
}
|
||||
|
||||
impl std::iter::Extend<Structure> for CapsRef {
|
||||
fn extend<T: IntoIterator<Item = Structure>>(&mut self, iter: T) {
|
||||
iter.into_iter().for_each(|s| self.append_structure(s));
|
||||
|
@ -224,6 +239,12 @@ impl std::iter::Extend<(Structure, Option<CapsFeatures>)> for CapsRef {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::iter::Extend<Caps> for CapsRef {
|
||||
fn extend<T: IntoIterator<Item = Caps>>(&mut self, iter: T) {
|
||||
iter.into_iter().for_each(|caps| self.append(caps));
|
||||
}
|
||||
}
|
||||
|
||||
impl CapsRef {
|
||||
#[doc(alias = "gst_caps_set_simple")]
|
||||
pub fn set_simple(&mut self, values: &[(&str, &(dyn ToSendValue + Sync))]) {
|
||||
|
|
Loading…
Reference in a new issue