diff --git a/gstreamer/src/caps.rs b/gstreamer/src/caps.rs index e33e09d7f..a5a54e87a 100644 --- a/gstreamer/src/caps.rs +++ b/gstreamer/src/caps.rs @@ -7,6 +7,7 @@ // except according to those terms. use std::fmt; +use std::str; use miniobject::*; use structure::*; @@ -58,6 +59,14 @@ impl GstRc { } } +impl str::FromStr for Caps { + type Err = (); + + fn from_str(s: &str) -> Result { + Caps::from_string(s).ok_or(()) + } +} + impl CapsRef { pub fn set_simple(&mut self, values: &[(&str, &glib::Value)]) { for &(name, ref value) in values { diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 07791dfa5..c7517f78c 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -9,6 +9,7 @@ use std::fmt; use std::ptr; use std::mem; +use std::str; use std::ffi::CStr; use std::ops::{Deref, DerefMut}; use std::borrow::{Borrow, ToOwned, BorrowMut}; @@ -123,6 +124,14 @@ impl PartialEq for Structure { impl Eq for Structure {} +impl str::FromStr for Structure { + type Err = (); + + fn from_str(s: &str) -> Result { + Structure::from_string(s).ok_or(()) + } +} + impl Borrow for Structure { fn borrow(&self) -> &StructureRef { unsafe { &*self.0 }