From 003ebbdf1c50b4fc4dc508354c4f0065916e71cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 19 Dec 2023 10:44:25 +0200 Subject: [PATCH] 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: --- gstreamer/Gir.toml | 10 +++++++++- gstreamer/src/structure.rs | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gstreamer/Gir.toml b/gstreamer/Gir.toml index 50963eae1..18c91519b 100644 --- a/gstreamer/Gir.toml +++ b/gstreamer/Gir.toml @@ -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" diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 61ceec6f8..7a3211913 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -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 { + 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 std::ops::ControlFlow<()>>( &self,