validate: Action.structure is nullable

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1586>
This commit is contained in:
Thibault Saunier 2024-11-08 17:54:15 -03:00 committed by GStreamer Marge Bot
parent e42b3c6bbe
commit b941e9c56a

View file

@ -12,19 +12,27 @@ gst::mini_object_wrapper!(Action, ActionRef, ffi::GstValidateAction, || {
}); });
impl ActionRef { impl ActionRef {
pub fn structure(&self) -> &gst::StructureRef { pub fn structure(&self) -> Option<&gst::StructureRef> {
unsafe { unsafe {
let action = &self.0 as *const ffi::GstValidateAction; let action = &self.0 as *const ffi::GstValidateAction;
gst::StructureRef::from_glib_borrow((*action).structure) if (*action).structure.is_null() {
None
} else {
Some(gst::StructureRef::from_glib_borrow((*action).structure))
}
} }
} }
pub fn structure_mut(&mut self) -> &mut gst::StructureRef { pub fn structure_mut(&mut self) -> Option<&mut gst::StructureRef> {
unsafe { unsafe {
let action = &mut self.0 as *mut ffi::GstValidateAction; let action = &mut self.0 as *mut ffi::GstValidateAction;
gst::StructureRef::from_glib_borrow_mut((*action).structure) if (*action).structure.is_null() {
None
} else {
Some(gst::StructureRef::from_glib_borrow_mut((*action).structure))
}
} }
} }