forked from mirrors/gstreamer-rs
gstreamer: Add FromIterator/Extend impls based on owned Strings and glib::Quark
This commit is contained in:
parent
a7be9ea9d9
commit
18e45dd991
2 changed files with 49 additions and 0 deletions
|
@ -413,6 +413,18 @@ impl<'a> std::iter::Extend<&'a str> for CapsFeaturesRef {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::iter::Extend<String> for CapsFeaturesRef {
|
||||
fn extend<T: IntoIterator<Item = String>>(&mut self, iter: T) {
|
||||
iter.into_iter().for_each(|f| self.add(&f));
|
||||
}
|
||||
}
|
||||
|
||||
impl std::iter::Extend<glib::Quark> for CapsFeaturesRef {
|
||||
fn extend<T: IntoIterator<Item = glib::Quark>>(&mut self, iter: T) {
|
||||
iter.into_iter().for_each(|f| self.add_from_quark(f));
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<'a> glib::value::FromValue<'a> for &'a CapsFeaturesRef {
|
||||
type Checker = glib::value::GenericValueTypeOrNoneChecker<Self>;
|
||||
|
||||
|
@ -547,6 +559,30 @@ impl<'a> std::iter::FromIterator<&'a str> for CapsFeatures {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::iter::FromIterator<String> for CapsFeatures {
|
||||
fn from_iter<T: IntoIterator<Item = String>>(iter: T) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
let mut features = CapsFeatures::new_empty();
|
||||
|
||||
iter.into_iter().for_each(|f| features.add(&f));
|
||||
|
||||
features
|
||||
}
|
||||
}
|
||||
|
||||
impl std::iter::FromIterator<glib::Quark> for CapsFeatures {
|
||||
fn from_iter<T: IntoIterator<Item = glib::Quark>>(iter: T) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
let mut features = CapsFeatures::new_empty();
|
||||
|
||||
iter.into_iter().for_each(|f| features.add_from_quark(f));
|
||||
|
||||
features
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for CapsFeaturesRef {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_tuple("CapsFeatures")
|
||||
|
|
|
@ -850,6 +850,19 @@ impl<'a> std::iter::Extend<(&'a str, SendValue)> for StructureRef {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::iter::Extend<(String, SendValue)> for StructureRef {
|
||||
fn extend<T: IntoIterator<Item = (String, SendValue)>>(&mut self, iter: T) {
|
||||
iter.into_iter().for_each(|(f, v)| self.set_value(&f, v));
|
||||
}
|
||||
}
|
||||
|
||||
impl std::iter::Extend<(glib::Quark, SendValue)> for StructureRef {
|
||||
fn extend<T: IntoIterator<Item = (glib::Quark, SendValue)>>(&mut self, iter: T) {
|
||||
iter.into_iter()
|
||||
.for_each(|(f, v)| self.set_value_by_quark(f, v));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Builder {
|
||||
s: Structure,
|
||||
|
|
Loading…
Reference in a new issue