mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 01:21:05 +00:00
structure: Manually bind GST_SERIALIZE_FLAG_STRICT
As the flag changes the nullability of `gst_structure_serialize()` and adding a new C function is apparently too much of a hassle for C developers, add a new `serialize_strict()` function here that always sets this flag and can fail. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1368>
This commit is contained in:
parent
0533160d94
commit
003ebbdf1c
2 changed files with 29 additions and 1 deletions
|
@ -32,7 +32,6 @@ generate = [
|
|||
"Gst.PromiseResult",
|
||||
"Gst.QOSType",
|
||||
"Gst.SchedulingFlags",
|
||||
"Gst.SerializeFlags",
|
||||
"Gst.StreamStatusType",
|
||||
"Gst.StreamType",
|
||||
"Gst.StructureChangeType",
|
||||
|
@ -2153,6 +2152,15 @@ status = "generate"
|
|||
name = "none"
|
||||
ignore = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.SerializeFlags"
|
||||
status = "generate"
|
||||
[[object.member]]
|
||||
name = "strict"
|
||||
# Changes nullability of gst_structure_serialize() so moved to a
|
||||
# separate function instead
|
||||
ignore = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.StackTraceFlags"
|
||||
status = "generate"
|
||||
|
|
|
@ -744,6 +744,26 @@ impl StructureRef {
|
|||
unsafe { from_glib_full(ffi::gst_structure_serialize(&self.0, flags.into_glib())) }
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
#[doc(alias = "gst_structure_serialize")]
|
||||
pub fn serialize_strict(
|
||||
&self,
|
||||
flags: crate::SerializeFlags,
|
||||
) -> Result<glib::GString, glib::BoolError> {
|
||||
unsafe {
|
||||
let res = ffi::gst_structure_serialize(
|
||||
&self.0,
|
||||
flags.into_glib() | ffi::GST_SERIALIZE_FLAG_STRICT,
|
||||
);
|
||||
if res.is_null() {
|
||||
Err(glib::bool_error!("Failed to serialize structure to string"))
|
||||
} else {
|
||||
Ok(from_glib_full(res))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_structure_foreach")]
|
||||
pub fn foreach<F: FnMut(glib::Quark, &glib::Value) -> std::ops::ControlFlow<()>>(
|
||||
&self,
|
||||
|
|
Loading…
Reference in a new issue