mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
Allow usage of Structures in GValues
This commit is contained in:
parent
a10d081c22
commit
2452f7f6a9
1 changed files with 21 additions and 2 deletions
|
@ -18,10 +18,12 @@ use std::marker::PhantomData;
|
||||||
use Fraction;
|
use Fraction;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::translate::{from_glib, from_glib_full, FromGlibPtrFull, FromGlibPtrNone, Stash,
|
use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlibPtrFull, FromGlibPtrNone,
|
||||||
StashMut, ToGlib, ToGlibPtr, ToGlibPtrMut};
|
GlibPtrDefault, Stash, StashMut, ToGlib, ToGlibPtr, ToGlibPtrMut};
|
||||||
use glib::value::{FromValueOptional, ToValue, Value};
|
use glib::value::{FromValueOptional, ToValue, Value};
|
||||||
use ffi;
|
use ffi;
|
||||||
|
use glib_ffi::gpointer;
|
||||||
|
use gobject_ffi;
|
||||||
|
|
||||||
pub struct Structure(*mut StructureRef, PhantomData<StructureRef>);
|
pub struct Structure(*mut StructureRef, PhantomData<StructureRef>);
|
||||||
|
|
||||||
|
@ -225,6 +227,23 @@ impl FromGlibPtrFull<*mut ffi::GstStructure> for Structure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> glib::value::FromValueOptional<'a> for Structure {
|
||||||
|
unsafe fn from_value_optional(v: &'a glib::Value) -> Option<Self> {
|
||||||
|
let ptr = gobject_ffi::g_value_get_boxed(v.to_glib_none().0);
|
||||||
|
from_glib_none(ptr as *const ffi::GstStructure)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl glib::value::SetValue for Structure {
|
||||||
|
unsafe fn set_value(v: &mut glib::Value, s: &Self) {
|
||||||
|
gobject_ffi::g_value_set_boxed(v.to_glib_none_mut().0, s.0 as gpointer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GlibPtrDefault for Structure {
|
||||||
|
type GlibType = *mut ffi::GstStructure;
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct StructureRef(ffi::GstStructure);
|
pub struct StructureRef(ffi::GstStructure);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue