gstreamer: Add Debug impl for MiniObject / MiniObjectRef

This commit is contained in:
Sebastian Dröge 2022-02-16 12:13:03 +02:00
parent b1f1c7dd4e
commit 849440403c

View file

@ -1,6 +1,7 @@
// Take a look at the license at the top of the repository in the LICENSE file. // Take a look at the license at the top of the repository in the LICENSE file.
use glib::translate::*; use glib::translate::*;
use std::fmt;
pub trait IsMiniObject: pub trait IsMiniObject:
AsRef<Self::RefType> + FromGlibPtrFull<*mut Self::FfiType> + Send + Sync + 'static AsRef<Self::RefType> + FromGlibPtrFull<*mut Self::FfiType> + Send + Sync + 'static
@ -553,6 +554,21 @@ impl MiniObject {
} }
} }
impl fmt::Debug for MiniObject {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.as_ref().fmt(f)
}
}
impl fmt::Debug for MiniObjectRef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("MiniObject")
.field("ptr", unsafe { &self.as_ptr() })
.field("type", &self.type_())
.finish()
}
}
impl MiniObjectRef { impl MiniObjectRef {
pub fn type_(&self) -> glib::Type { pub fn type_(&self) -> glib::Type {
unsafe { from_glib((*self.as_ptr()).type_) } unsafe { from_glib((*self.as_ptr()).type_) }