From 721de958cefd5278019cf78031ab99ed078e50c4 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 30 Oct 2024 18:19:52 -0300 Subject: [PATCH] validate: Implement Debug trait on Action Part-of: --- gstreamer-validate/src/action.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gstreamer-validate/src/action.rs b/gstreamer-validate/src/action.rs index 3a5678db4..4b9d2640d 100644 --- a/gstreamer-validate/src/action.rs +++ b/gstreamer-validate/src/action.rs @@ -1,5 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use std::ffi::CStr; + use glib::prelude::*; use glib::translate::*; @@ -55,6 +57,13 @@ impl Action { } } + pub fn name(&self) -> &str { + unsafe { + let action: *mut ffi::GstValidateAction = self.to_glib_none().0; + CStr::from_ptr((*action).name).to_str().unwrap() + } + } + #[doc(alias = "gst_validate_execute_action")] pub fn execute(&self) -> Result { unsafe { @@ -71,3 +80,12 @@ impl Action { } } } + +impl std::fmt::Debug for Action { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("Action") + .field("structure", &self.structure()) + .field("name", &self.name()) + .finish() + } +}