Commit 5e58998c authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Implement FromStr for Caps and Structure

parent a94d4d58
......@@ -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<CapsRef> {
}
}
impl str::FromStr for Caps {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
Caps::from_string(s).ok_or(())
}
}
impl CapsRef {
pub fn set_simple(&mut self, values: &[(&str, &glib::Value)]) {
for &(name, ref value) in values {
......
......@@ -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<StructureRef> for Structure {
impl Eq for Structure {}
impl str::FromStr for Structure {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
Structure::from_string(s).ok_or(())
}
}
impl Borrow<StructureRef> for Structure {
fn borrow(&self) -> &StructureRef {
unsafe { &*self.0 }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment