mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-29 04:51:09 +00:00
gstreamer: Value::deserialize() needs to take the target type as parameter
Otherwise it will always fail.
This commit is contained in:
parent
562c8563ce
commit
dd4330f899
1 changed files with 19 additions and 3 deletions
|
@ -836,7 +836,10 @@ pub trait GstValueExt: Sized {
|
||||||
#[doc(alias = "gst_value_serialize")]
|
#[doc(alias = "gst_value_serialize")]
|
||||||
fn serialize(&self) -> Result<glib::GString, glib::BoolError>;
|
fn serialize(&self) -> Result<glib::GString, glib::BoolError>;
|
||||||
#[doc(alias = "gst_value_deserialize")]
|
#[doc(alias = "gst_value_deserialize")]
|
||||||
fn deserialize<'a, T: Into<&'a str>>(s: T) -> Result<glib::Value, glib::BoolError>;
|
fn deserialize<'a, T: Into<&'a str>>(
|
||||||
|
s: T,
|
||||||
|
type_: glib::Type,
|
||||||
|
) -> Result<glib::Value, glib::BoolError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GstValueExt for glib::Value {
|
impl GstValueExt for glib::Value {
|
||||||
|
@ -976,13 +979,16 @@ impl GstValueExt for glib::Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize<'a, T: Into<&'a str>>(s: T) -> Result<glib::Value, glib::BoolError> {
|
fn deserialize<'a, T: Into<&'a str>>(
|
||||||
|
s: T,
|
||||||
|
type_: glib::Type,
|
||||||
|
) -> Result<glib::Value, glib::BoolError> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
let s = s.into();
|
let s = s.into();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut value = glib::Value::uninitialized();
|
let mut value = glib::Value::from_type(type_);
|
||||||
let ret: bool = from_glib(ffi::gst_value_deserialize(
|
let ret: bool = from_glib(ffi::gst_value_deserialize(
|
||||||
value.to_glib_none_mut().0,
|
value.to_glib_none_mut().0,
|
||||||
s.to_glib_none().0,
|
s.to_glib_none().0,
|
||||||
|
@ -998,6 +1004,8 @@ impl GstValueExt for glib::Value {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fraction() {
|
fn test_fraction() {
|
||||||
crate::init().unwrap();
|
crate::init().unwrap();
|
||||||
|
@ -1011,4 +1019,12 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(f3, crate::Fraction::new(2, 27));
|
assert_eq!(f3, crate::Fraction::new(2, 27));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_deserialize() {
|
||||||
|
crate::init().unwrap();
|
||||||
|
|
||||||
|
let v = glib::Value::deserialize("123", i32::static_type()).unwrap();
|
||||||
|
assert_eq!(v.get::<i32>(), Ok(123));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue