Add more Debug impls to everything possible

This commit is contained in:
Sebastian Dröge 2019-01-22 17:43:29 +02:00
parent cc3c3876ab
commit bd0cbe99b3
36 changed files with 91 additions and 6 deletions

View file

@ -37,6 +37,7 @@ impl fmt::Debug for AudioInfo {
}
}
#[derive(Debug)]
pub struct AudioInfoBuilder<'a> {
format: ::AudioFormat,
rate: u32,

View file

@ -13,7 +13,7 @@ use gobject_ffi;
use gst;
glib_wrapper! {
#[derive(Debug)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FlowCombiner(Shared<ffi::GstFlowCombiner>);
match fn {

View file

@ -10,6 +10,7 @@
use DiscovererStreamInfo;
use DiscovererStreamInfoExt;
#[derive(Debug)]
pub struct Iter {
stream_info: Option<DiscovererStreamInfo>,
direction_forward: bool,

View file

@ -255,6 +255,7 @@ impl error::Error for EncodingProfileBuilderError {
}
}
#[derive(Debug)]
struct EncodingProfileBuilderCommonData<'a> {
name: Option<&'a str>,
description: Option<&'a str>,
@ -360,6 +361,7 @@ fn set_common_fields<T: EncodingProfileBuilderCommon>(
profile.set_presence(base_data.presence);
}
#[derive(Debug)]
pub struct EncodingAudioProfileBuilder<'a> {
base: EncodingProfileBuilderCommonData<'a>,
}
@ -390,6 +392,7 @@ impl<'a> EncodingAudioProfileBuilder<'a> {
}
}
#[derive(Debug)]
pub struct EncodingVideoProfileBuilder<'a> {
base: EncodingProfileBuilderCommonData<'a>,
pass: u32,
@ -437,6 +440,7 @@ impl<'a> EncodingVideoProfileBuilder<'a> {
}
}
#[derive(Debug)]
pub struct EncodingContainerProfileBuilder<'a> {
base: EncodingProfileBuilderCommonData<'a>,
profiles: Vec<EncodingProfile>,

View file

@ -8,9 +8,10 @@
use ffi;
use glib;
use std::ptr;
#[derive(PartialEq, Eq)]
pub struct RTSPContext(*mut ffi::GstRTSPContext);
#[derive(Debug, PartialEq, Eq)]
pub struct RTSPContext(ptr::NonNull<ffi::GstRTSPContext>);
impl RTSPContext {
pub fn with_current_context<F: FnOnce(&RTSPContext) -> T, T>(func: F) -> Option<T> {
@ -20,7 +21,7 @@ impl RTSPContext {
return None;
}
let ctx = RTSPContext(ptr);
let ctx = RTSPContext(ptr::NonNull::new_unchecked(ptr));
Some(func(&ctx))
}
}
@ -32,6 +33,7 @@ impl RTSPContext {
impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstRTSPContext> for RTSPContext {
#[inline]
unsafe fn from_glib_borrow(ptr: *mut ffi::GstRTSPContext) -> Self {
RTSPContext(ptr)
assert!(!ptr.is_null());
RTSPContext(ptr::NonNull::new_unchecked(ptr))
}
}

View file

@ -8,4 +8,6 @@
use ffi;
#[repr(C)]
#[derive(Debug)]
pub struct MIKEYDecryptInfo(ffi::GstMIKEYDecryptInfo);

View file

@ -8,4 +8,6 @@
use ffi;
#[repr(C)]
#[derive(Debug)]
pub struct MIKEYEncryptInfo(ffi::GstMIKEYEncryptInfo);

View file

@ -9,6 +9,7 @@
use ffi;
#[repr(C)]
#[derive(Debug)]
pub struct MIKEYMapSRTP(ffi::GstMIKEYMapSRTP);
impl MIKEYMapSRTP {

View file

@ -11,6 +11,7 @@ use std::slice;
use ffi;
#[repr(C)]
#[derive(Debug)]
pub struct MIKEYPayloadSPParam(ffi::GstMIKEYPayloadSPParam);
impl MIKEYPayloadSPParam {

View file

@ -13,6 +13,7 @@ use ffi;
use glib::translate::*;
#[repr(C)]
#[derive(Debug)]
pub struct SDPAttribute(pub(crate) ffi::GstSDPAttribute);
impl SDPAttribute {

View file

@ -13,6 +13,7 @@ use ffi;
use glib::translate::*;
#[repr(C)]
#[derive(Debug)]
pub struct SDPBandwidth(pub(crate) ffi::GstSDPBandwidth);
impl SDPBandwidth {

View file

@ -13,6 +13,7 @@ use ffi;
use glib::translate::*;
#[repr(C)]
#[derive(Debug)]
pub struct SDPConnection(pub(crate) ffi::GstSDPConnection);
impl SDPConnection {

View file

@ -10,6 +10,8 @@ use std::ffi::CStr;
use ffi;
#[repr(C)]
#[derive(Debug)]
pub struct SDPKey(ffi::GstSDPKey);
impl SDPKey {

View file

@ -23,6 +23,7 @@ use sdp_key::SDPKey;
use MIKEYMessage;
glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SDPMedia(Boxed<ffi::GstSDPMedia>);
match fn {

View file

@ -31,6 +31,7 @@ use sdp_zone::SDPZone;
use MIKEYMessage;
glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SDPMessage(Boxed<ffi::GstSDPMessage>);
match fn {

View file

@ -11,6 +11,7 @@ use std::ffi::CStr;
use ffi;
#[repr(C)]
#[derive(Debug)]
pub struct SDPOrigin(pub(crate) ffi::GstSDPOrigin);
impl SDPOrigin {

View file

@ -14,6 +14,7 @@ use ffi;
use glib::translate::*;
#[repr(C)]
#[derive(Debug)]
pub struct SDPTime(pub(crate) ffi::GstSDPTime);
impl SDPTime {

View file

@ -13,6 +13,7 @@ use ffi;
use glib::translate::*;
#[repr(C)]
#[derive(Debug)]
pub struct SDPZone(pub(crate) ffi::GstSDPZone);
impl SDPZone {

View file

@ -23,6 +23,7 @@ use std::slice;
pub enum Readable {}
pub enum Writable {}
#[derive(Debug)]
pub struct VideoFrame<T>(
ffi::GstVideoFrame,
Option<gst::Buffer>,
@ -338,6 +339,7 @@ impl VideoFrame<Writable> {
}
}
#[derive(Debug)]
pub struct VideoFrameRef<T>(ffi::GstVideoFrame, Option<T>, ::VideoInfo, bool);
impl<'a> VideoFrameRef<&'a gst::BufferRef> {

View file

@ -221,6 +221,7 @@ impl fmt::Debug for VideoInfo {
}
}
#[derive(Debug)]
pub struct VideoInfoBuilder<'a> {
format: ::VideoFormat,
width: u32,

View file

@ -402,6 +402,7 @@ impl BufferRef {
macro_rules! define_iter(
($name:ident, $typ:ty, $mtyp:ty, $prepare_buffer:expr, $from_ptr:expr) => {
#[derive(Debug)]
pub struct $name<'a, T: MetaAPI + 'a> {
buffer: $typ,
state: glib_ffi::gpointer,

View file

@ -119,6 +119,7 @@ impl fmt::Debug for BufferListRef {
}
}
#[derive(Debug)]
pub struct Iter<'a> {
list: &'a BufferListRef,
idx: u32,

View file

@ -150,6 +150,7 @@ impl Bus {
}
}
#[derive(Debug)]
pub struct Iter<'a> {
bus: &'a Bus,
timeout: ::ClockTime,
@ -171,6 +172,7 @@ mod futures {
use futures_core::{Async, Poll};
use std::sync::{Arc, Mutex};
#[derive(Debug)]
pub struct BusStream(Bus, Arc<Mutex<Option<Waker>>>);
impl BusStream {

View file

@ -343,6 +343,7 @@ impl CapsRef {
macro_rules! define_iter(
($name:ident, $typ:ty, $styp:ty, $get_item:expr) => {
#[derive(Debug)]
pub struct $name<'a> {
caps: $typ,
idx: u32,
@ -491,6 +492,7 @@ impl PartialEq for CapsRef {
impl Eq for CapsRef {}
#[derive(Debug)]
pub struct Builder<'a> {
s: ::Structure,
features: Option<&'a [&'a str]>,

View file

@ -364,6 +364,7 @@ impl CapsFeaturesRef {
}
}
#[derive(Debug)]
pub struct Iter<'a> {
caps_features: &'a CapsFeaturesRef,
idx: u32,

View file

@ -24,6 +24,7 @@ use ClockTime;
use ClockTimeDiff;
glib_wrapper! {
#[derive(Debug, Hash)]
pub struct ClockId(Shared<c_void>);
match fn {

View file

@ -48,6 +48,7 @@ impl Error for IteratorError {
}
// Implemented manually so that we can use generics for the item
#[derive(Debug)]
pub struct Iterator<T> {
iter: ptr::NonNull<ffi::GstIterator>,
borrowed: bool,

View file

@ -82,6 +82,7 @@ impl FromGlib<libc::c_ulong> for PadProbeId {
}
}
#[derive(Debug)]
pub struct PadProbeInfo<'a> {
pub mask: PadProbeType,
pub id: PadProbeId,
@ -90,6 +91,7 @@ pub struct PadProbeInfo<'a> {
pub data: Option<PadProbeData<'a>>,
}
#[derive(Debug)]
pub enum PadProbeData<'a> {
Buffer(Buffer),
BufferList(BufferList),
@ -99,6 +101,7 @@ pub enum PadProbeData<'a> {
__Unknown(*mut ffi::GstMiniObject),
}
#[derive(Debug)]
pub struct StreamLock(Pad);
impl Drop for StreamLock {
fn drop(&mut self) {

View file

@ -11,6 +11,7 @@ use glib::translate::*;
use gobject_ffi;
glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ParseContext(Boxed<ffi::GstParseContext>);
match fn {

View file

@ -14,6 +14,7 @@ use Structure;
use StructureRef;
glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Promise(Shared<ffi::GstPromise>);
match fn {

View file

@ -15,6 +15,8 @@ use gobject_ffi;
use glib;
use glib::translate::{from_glib_full, FromGlibPtrNone, ToGlibPtr, ToGlibPtrMut};
use std::ffi::CStr;
use std::fmt;
use std::ptr;
#[repr(C)]
@ -29,6 +31,16 @@ impl StaticCaps {
unsafe impl Send for StaticCaps {}
unsafe impl Sync for StaticCaps {}
impl fmt::Debug for StaticCaps {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("StaticCaps")
.field("str", &unsafe {
CStr::from_ptr(self.0.as_ref().string).to_str()
})
.finish()
}
}
impl glib::types::StaticType for StaticCaps {
fn static_type() -> glib::types::Type {
unsafe { glib::translate::from_glib(ffi::gst_static_caps_get_type()) }

View file

@ -14,9 +14,12 @@ use glib_ffi;
use gobject_ffi;
use glib;
use glib::translate::{from_glib, from_glib_full, FromGlibPtrNone, ToGlibPtr, ToGlibPtrMut};
use glib::translate::{
from_glib, from_glib_full, from_glib_none, FromGlibPtrNone, ToGlibPtr, ToGlibPtrMut,
};
use std::ffi::CStr;
use std::fmt;
use std::ptr;
#[repr(C)]
@ -51,6 +54,25 @@ impl StaticPadTemplate {
unsafe impl Send for StaticPadTemplate {}
unsafe impl Sync for StaticPadTemplate {}
impl fmt::Debug for StaticPadTemplate {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("StaticPadTemplate")
.field("name_template", &unsafe {
CStr::from_ptr(self.0.as_ref().name_template).to_str()
})
.field("direction", &unsafe {
from_glib::<_, ::PadDirection>(self.0.as_ref().direction)
})
.field("presence", &unsafe {
from_glib::<_, ::PadPresence>(self.0.as_ref().presence)
})
.field("static_caps", &unsafe {
from_glib_none::<_, ::StaticCaps>(&self.0.as_ref().static_caps as *const _)
})
.finish()
}
}
impl glib::types::StaticType for StaticPadTemplate {
fn static_type() -> glib::types::Type {
unsafe { glib::translate::from_glib(ffi::gst_static_pad_template_get_type()) }

View file

@ -12,6 +12,7 @@ use glib::translate::*;
use Stream;
use StreamCollection;
#[derive(Debug)]
pub struct Iter<'a> {
collection: &'a StreamCollection,
idx: u32,

View file

@ -532,6 +532,7 @@ impl PartialEq for StructureRef {
impl Eq for StructureRef {}
#[derive(Debug)]
pub struct FieldIterator<'a> {
structure: &'a StructureRef,
idx: u32,
@ -595,6 +596,7 @@ impl<'a> DoubleEndedIterator for FieldIterator<'a> {
impl<'a> ExactSizeIterator for FieldIterator<'a> {}
#[derive(Debug)]
pub struct Iter<'a> {
iter: FieldIterator<'a>,
}
@ -638,6 +640,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
impl<'a> ExactSizeIterator for Iter<'a> {}
#[derive(Debug)]
pub struct Builder {
s: Structure,
}

View file

@ -518,6 +518,7 @@ impl PartialEq for TagListRef {
impl Eq for TagListRef {}
#[derive(Debug)]
pub struct TagIter<'a, T: Tag<'a>> {
taglist: &'a TagListRef,
idx: u32,
@ -588,6 +589,7 @@ where
{
}
#[derive(Debug)]
pub struct GenericTagIter<'a> {
taglist: &'a TagListRef,
name: &'a str,
@ -645,6 +647,7 @@ impl<'a> DoubleEndedIterator for GenericTagIter<'a> {
impl<'a> ExactSizeIterator for GenericTagIter<'a> {}
#[derive(Debug)]
pub struct GenericIter<'a> {
taglist: &'a TagListRef,
idx: u32,
@ -703,6 +706,7 @@ impl<'a> DoubleEndedIterator for GenericIter<'a> {
impl<'a> ExactSizeIterator for GenericIter<'a> {}
#[derive(Debug)]
pub struct Iter<'a> {
taglist: &'a TagListRef,
idx: u32,

View file

@ -21,6 +21,7 @@ use std::ptr;
use std::slice;
#[repr(C)]
#[derive(Debug)]
pub struct TypeFind<'a>(ffi::GstTypeFind, PhantomData<&'a ()>);
pub trait TypeFindImpl {
@ -152,6 +153,7 @@ unsafe extern "C" fn type_find_get_length(data: glib_ffi::gpointer) -> u64 {
find.get_length().unwrap_or(u64::MAX)
}
#[derive(Debug)]
pub struct SliceTypeFind<T: AsRef<[u8]>> {
pub probability: Option<TypeFindProbability>,
pub caps: Option<Caps>,