Implement FromStr for Caps and Structure

This commit is contained in:
Sebastian Dröge 2017-07-13 14:57:02 +03:00
parent a94d4d583d
commit 5e58998c76
2 changed files with 18 additions and 0 deletions

View file

@ -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 {

View file

@ -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 }