From 85b335fd898fa1f8291ff21a6726b90f7a763d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 10 Sep 2017 14:54:43 +0300 Subject: [PATCH] Fix/hide various clippy warnings in gstreamer --- gstreamer/src/buffer.rs | 6 ++ gstreamer/src/bufferlist.rs | 10 +++ gstreamer/src/bus.rs | 3 + gstreamer/src/clock.rs | 2 + gstreamer/src/event.rs | 95 ++++++++------------- gstreamer/src/iterator.rs | 1 + gstreamer/src/lib.rs | 1 + gstreamer/src/message.rs | 146 ++++++++++++--------------------- gstreamer/src/miniobject.rs | 2 + gstreamer/src/pad.rs | 1 + gstreamer/src/parse_context.rs | 6 ++ gstreamer/src/query.rs | 58 +++++-------- gstreamer/src/segment.rs | 7 ++ gstreamer/src/tags.rs | 6 ++ 14 files changed, 154 insertions(+), 190 deletions(-) diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index b6fd6b642..27ad7c2bd 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -142,6 +142,12 @@ impl GstRc { } } +impl Default for GstRc { + fn default() -> Self { + Self::new() + } +} + impl BufferRef { pub fn map_readable(&self) -> Option> { let mut map_info: ffi::GstMapInfo = unsafe { mem::zeroed() }; diff --git a/gstreamer/src/bufferlist.rs b/gstreamer/src/bufferlist.rs index c7c21f87e..8a910a661 100644 --- a/gstreamer/src/bufferlist.rs +++ b/gstreamer/src/bufferlist.rs @@ -68,11 +68,21 @@ impl BufferListRef { unsafe { ffi::gst_buffer_list_length(self.as_mut_ptr()) as usize } } + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + pub fn iter(&self) -> Iter { Iter::new(self) } } +impl Default for GstRc { + fn default() -> Self { + Self::new() + } +} + impl ToOwned for BufferListRef { type Owned = GstRc; diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index 85fac8e53..735f6dea4 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -37,6 +37,7 @@ unsafe extern "C" fn trampoline_watch( func: gpointer, ) -> gboolean { let _guard = CallbackGuard::new(); + #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let func: &RefCell Continue + Send + 'static>> = transmute(func); (&mut *func.borrow_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib() } @@ -49,6 +50,7 @@ unsafe extern "C" fn destroy_closure_watch(ptr: gpointer) { } fn into_raw_watch Continue + Send + 'static>(func: F) -> gpointer { + #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] let func: Box Continue + Send + 'static>>> = Box::new(RefCell::new(Box::new(func))); Box::into_raw(func) as gpointer @@ -60,6 +62,7 @@ unsafe extern "C" fn trampoline_sync( func: gpointer, ) -> ffi::GstBusSyncReply { let _guard = CallbackGuard::new(); + #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let f: &&(Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static) = transmute(func); f(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib() } diff --git a/gstreamer/src/clock.rs b/gstreamer/src/clock.rs index 5f347f503..bd9ff82d1 100644 --- a/gstreamer/src/clock.rs +++ b/gstreamer/src/clock.rs @@ -39,6 +39,7 @@ unsafe extern "C" fn trampoline_wait_async( func: gpointer, ) -> gboolean { let _guard = CallbackGuard::new(); + #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let f: &&(Fn(&Clock, ClockTime, &ClockId) -> bool + Send + 'static) = transmute(func); f(&from_glib_borrow(clock), time, &from_glib_borrow(id)).to_glib() } @@ -51,6 +52,7 @@ unsafe extern "C" fn destroy_closure_wait_async(ptr: gpointer) { fn into_raw_wait_async bool + Send + 'static>( func: F, ) -> gpointer { + #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] let func: Box bool + Send + 'static>> = Box::new(Box::new(func)); Box::into_raw(func) as gpointer diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 4501f2489..d8695eee5 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -69,66 +69,41 @@ impl EventRef { pub fn view(&self) -> EventView { let type_ = unsafe { (*self.as_ptr()).type_ }; - if type_ == ffi::GST_EVENT_FLUSH_START { - EventView::FlushStart(FlushStart(self)) - } else if type_ == ffi::GST_EVENT_FLUSH_STOP { - EventView::FlushStop(FlushStop(self)) - } else if type_ == ffi::GST_EVENT_STREAM_START { - EventView::StreamStart(StreamStart(self)) - } else if type_ == ffi::GST_EVENT_CAPS { - EventView::Caps(Caps(self)) - } else if type_ == ffi::GST_EVENT_SEGMENT { - EventView::Segment(Segment(self)) - } else if type_ == ffi::GST_EVENT_STREAM_COLLECTION { - EventView::StreamCollection(StreamCollection(self)) - } else if type_ == ffi::GST_EVENT_TAG { - EventView::Tag(Tag(self)) - } else if type_ == ffi::GST_EVENT_BUFFERSIZE { - EventView::BufferSize(BufferSize(self)) - } else if type_ == ffi::GST_EVENT_SINK_MESSAGE { - EventView::SinkMessage(SinkMessage(self)) - } else if type_ == ffi::GST_EVENT_STREAM_GROUP_DONE { - EventView::StreamGroupDone(StreamGroupDone(self)) - } else if type_ == ffi::GST_EVENT_EOS { - EventView::Eos(Eos(self)) - } else if type_ == ffi::GST_EVENT_TOC { - EventView::Toc(Toc(self)) - } else if type_ == ffi::GST_EVENT_PROTECTION { - EventView::Protection(Protection(self)) - } else if type_ == ffi::GST_EVENT_SEGMENT_DONE { - EventView::SegmentDone(SegmentDone(self)) - } else if type_ == ffi::GST_EVENT_GAP { - EventView::Gap(Gap(self)) - } else if type_ == ffi::GST_EVENT_QOS { - EventView::Qos(Qos(self)) - } else if type_ == ffi::GST_EVENT_SEEK { - EventView::Seek(Seek(self)) - } else if type_ == ffi::GST_EVENT_NAVIGATION { - EventView::Navigation(Navigation(self)) - } else if type_ == ffi::GST_EVENT_LATENCY { - EventView::Latency(Latency(self)) - } else if type_ == ffi::GST_EVENT_STEP { - EventView::Step(Step(self)) - } else if type_ == ffi::GST_EVENT_RECONFIGURE { - EventView::Reconfigure(Reconfigure(self)) - } else if type_ == ffi::GST_EVENT_TOC_SELECT { - EventView::TocSelect(TocSelect(self)) - } else if type_ == ffi::GST_EVENT_SELECT_STREAMS { - EventView::SelectStreams(SelectStreams(self)) - } else if type_ == ffi::GST_EVENT_CUSTOM_UPSTREAM { - EventView::CustomUpstream(CustomUpstream(self)) - } else if type_ == ffi::GST_EVENT_CUSTOM_DOWNSTREAM { - EventView::CustomDownstream(CustomDownstream(self)) - } else if type_ == ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB { - EventView::CustomDownstreamOob(CustomDownstreamOob(self)) - } else if type_ == ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY { - EventView::CustomDownstreamSticky(CustomDownstreamSticky(self)) - } else if type_ == ffi::GST_EVENT_CUSTOM_BOTH { - EventView::CustomBoth(CustomBoth(self)) - } else if type_ == ffi::GST_EVENT_CUSTOM_BOTH_OOB { - EventView::CustomBothOob(CustomBothOob(self)) - } else { - EventView::Other + match type_ { + ffi::GST_EVENT_FLUSH_START => EventView::FlushStart(FlushStart(self)), + ffi::GST_EVENT_FLUSH_STOP => EventView::FlushStop(FlushStop(self)), + ffi::GST_EVENT_STREAM_START => EventView::StreamStart(StreamStart(self)), + ffi::GST_EVENT_CAPS => EventView::Caps(Caps(self)), + ffi::GST_EVENT_SEGMENT => EventView::Segment(Segment(self)), + ffi::GST_EVENT_STREAM_COLLECTION => EventView::StreamCollection(StreamCollection(self)), + ffi::GST_EVENT_TAG => EventView::Tag(Tag(self)), + ffi::GST_EVENT_BUFFERSIZE => EventView::BufferSize(BufferSize(self)), + ffi::GST_EVENT_SINK_MESSAGE => EventView::SinkMessage(SinkMessage(self)), + ffi::GST_EVENT_STREAM_GROUP_DONE => EventView::StreamGroupDone(StreamGroupDone(self)), + ffi::GST_EVENT_EOS => EventView::Eos(Eos(self)), + ffi::GST_EVENT_TOC => EventView::Toc(Toc(self)), + ffi::GST_EVENT_PROTECTION => EventView::Protection(Protection(self)), + ffi::GST_EVENT_SEGMENT_DONE => EventView::SegmentDone(SegmentDone(self)), + ffi::GST_EVENT_GAP => EventView::Gap(Gap(self)), + ffi::GST_EVENT_QOS => EventView::Qos(Qos(self)), + ffi::GST_EVENT_SEEK => EventView::Seek(Seek(self)), + ffi::GST_EVENT_NAVIGATION => EventView::Navigation(Navigation(self)), + ffi::GST_EVENT_LATENCY => EventView::Latency(Latency(self)), + ffi::GST_EVENT_STEP => EventView::Step(Step(self)), + ffi::GST_EVENT_RECONFIGURE => EventView::Reconfigure(Reconfigure(self)), + ffi::GST_EVENT_TOC_SELECT => EventView::TocSelect(TocSelect(self)), + ffi::GST_EVENT_SELECT_STREAMS => EventView::SelectStreams(SelectStreams(self)), + ffi::GST_EVENT_CUSTOM_UPSTREAM => EventView::CustomUpstream(CustomUpstream(self)), + ffi::GST_EVENT_CUSTOM_DOWNSTREAM => EventView::CustomDownstream(CustomDownstream(self)), + ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB => { + EventView::CustomDownstreamOob(CustomDownstreamOob(self)) + } + ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY => { + EventView::CustomDownstreamSticky(CustomDownstreamSticky(self)) + } + ffi::GST_EVENT_CUSTOM_BOTH => EventView::CustomBoth(CustomBoth(self)), + ffi::GST_EVENT_CUSTOM_BOTH_OOB => EventView::CustomBothOob(CustomBothOob(self)), + _ => EventView::Other, } } } diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index d76dfdd6e..dfb67a4f3 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -21,6 +21,7 @@ glib_wrapper! { } impl Iterator { + #[cfg_attr(feature = "cargo-clippy", allow(should_implement_trait))] pub fn next(&mut self) -> Result { unsafe { let mut value = Value::uninitialized(); diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index ab47ce624..58d16b5f4 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -52,6 +52,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] +#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] mod auto; pub use auto::*; pub use auto::functions::*; diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index 45e46fce0..ee5e29edf 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -49,80 +49,52 @@ impl MessageRef { pub fn view(&self) -> MessageView { let type_ = unsafe { (*self.as_ptr()).type_ }; - if type_ == ffi::GST_MESSAGE_EOS { - MessageView::Eos(Eos(self)) - } else if type_ == ffi::GST_MESSAGE_ERROR { - MessageView::Error(Error(self)) - } else if type_ == ffi::GST_MESSAGE_WARNING { - MessageView::Warning(Warning(self)) - } else if type_ == ffi::GST_MESSAGE_INFO { - MessageView::Info(Info(self)) - } else if type_ == ffi::GST_MESSAGE_TAG { - MessageView::Tag(Tag(self)) - } else if type_ == ffi::GST_MESSAGE_BUFFERING { - MessageView::Buffering(Buffering(self)) - } else if type_ == ffi::GST_MESSAGE_STATE_CHANGED { - MessageView::StateChanged(StateChanged(self)) - } else if type_ == ffi::GST_MESSAGE_STATE_DIRTY { - MessageView::StateDirty(StateDirty(self)) - } else if type_ == ffi::GST_MESSAGE_STEP_DONE { - MessageView::StepDone(StepDone(self)) - } else if type_ == ffi::GST_MESSAGE_CLOCK_PROVIDE { - MessageView::ClockProvide(ClockProvide(self)) - } else if type_ == ffi::GST_MESSAGE_CLOCK_LOST { - MessageView::ClockLost(ClockLost(self)) - } else if type_ == ffi::GST_MESSAGE_NEW_CLOCK { - MessageView::NewClock(NewClock(self)) - } else if type_ == ffi::GST_MESSAGE_STRUCTURE_CHANGE { - MessageView::StructureChange(StructureChange(self)) - } else if type_ == ffi::GST_MESSAGE_STREAM_STATUS { - MessageView::StreamStatus(StreamStatus(self)) - } else if type_ == ffi::GST_MESSAGE_APPLICATION { - MessageView::Application(Application(self)) - } else if type_ == ffi::GST_MESSAGE_ELEMENT { - MessageView::Element(Element(self)) - } else if type_ == ffi::GST_MESSAGE_SEGMENT_START { - MessageView::SegmentStart(SegmentStart(self)) - } else if type_ == ffi::GST_MESSAGE_SEGMENT_DONE { - MessageView::SegmentDone(SegmentDone(self)) - } else if type_ == ffi::GST_MESSAGE_DURATION_CHANGED { - MessageView::DurationChanged(DurationChanged(self)) - } else if type_ == ffi::GST_MESSAGE_LATENCY { - MessageView::Latency(Latency(self)) - } else if type_ == ffi::GST_MESSAGE_ASYNC_START { - MessageView::AsyncStart(AsyncStart(self)) - } else if type_ == ffi::GST_MESSAGE_ASYNC_DONE { - MessageView::AsyncDone(AsyncDone(self)) - } else if type_ == ffi::GST_MESSAGE_REQUEST_STATE { - MessageView::RequestState(RequestState(self)) - } else if type_ == ffi::GST_MESSAGE_STEP_START { - MessageView::StepStart(StepStart(self)) - } else if type_ == ffi::GST_MESSAGE_QOS { - MessageView::Qos(Qos(self)) - } else if type_ == ffi::GST_MESSAGE_PROGRESS { - MessageView::Progress(Progress(self)) - } else if type_ == ffi::GST_MESSAGE_TOC { - MessageView::Toc(Toc(self)) - } else if type_ == ffi::GST_MESSAGE_RESET_TIME { - MessageView::ResetTime(ResetTime(self)) - } else if type_ == ffi::GST_MESSAGE_STREAM_START { - MessageView::StreamStart(StreamStart(self)) - } else if type_ == ffi::GST_MESSAGE_NEED_CONTEXT { - MessageView::NeedContext(NeedContext(self)) - } else if type_ == ffi::GST_MESSAGE_HAVE_CONTEXT { - MessageView::HaveContext(HaveContext(self)) - } else if type_ == ffi::GST_MESSAGE_DEVICE_ADDED { - MessageView::DeviceAdded(DeviceAdded(self)) - } else if type_ == ffi::GST_MESSAGE_DEVICE_REMOVED { - MessageView::DeviceRemoved(DeviceRemoved(self)) - } else if type_ == ffi::GST_MESSAGE_PROPERTY_NOTIFY { - MessageView::PropertyNotify(PropertyNotify(self)) - } else if type_ == ffi::GST_MESSAGE_STREAM_COLLECTION { - MessageView::StreamCollection(StreamCollection(self)) - } else if type_ == ffi::GST_MESSAGE_STREAMS_SELECTED { - MessageView::StreamsSelected(StreamsSelected(self)) - } else { - MessageView::Other + match type_ { + ffi::GST_MESSAGE_EOS => MessageView::Eos(Eos(self)), + ffi::GST_MESSAGE_ERROR => MessageView::Error(Error(self)), + ffi::GST_MESSAGE_WARNING => MessageView::Warning(Warning(self)), + ffi::GST_MESSAGE_INFO => MessageView::Info(Info(self)), + ffi::GST_MESSAGE_TAG => MessageView::Tag(Tag(self)), + ffi::GST_MESSAGE_BUFFERING => MessageView::Buffering(Buffering(self)), + ffi::GST_MESSAGE_STATE_CHANGED => MessageView::StateChanged(StateChanged(self)), + ffi::GST_MESSAGE_STATE_DIRTY => MessageView::StateDirty(StateDirty(self)), + ffi::GST_MESSAGE_STEP_DONE => MessageView::StepDone(StepDone(self)), + ffi::GST_MESSAGE_CLOCK_PROVIDE => MessageView::ClockProvide(ClockProvide(self)), + ffi::GST_MESSAGE_CLOCK_LOST => MessageView::ClockLost(ClockLost(self)), + ffi::GST_MESSAGE_NEW_CLOCK => MessageView::NewClock(NewClock(self)), + ffi::GST_MESSAGE_STRUCTURE_CHANGE => { + MessageView::StructureChange(StructureChange(self)) + } + ffi::GST_MESSAGE_STREAM_STATUS => MessageView::StreamStatus(StreamStatus(self)), + ffi::GST_MESSAGE_APPLICATION => MessageView::Application(Application(self)), + ffi::GST_MESSAGE_ELEMENT => MessageView::Element(Element(self)), + ffi::GST_MESSAGE_SEGMENT_START => MessageView::SegmentStart(SegmentStart(self)), + ffi::GST_MESSAGE_SEGMENT_DONE => MessageView::SegmentDone(SegmentDone(self)), + ffi::GST_MESSAGE_DURATION_CHANGED => { + MessageView::DurationChanged(DurationChanged(self)) + } + ffi::GST_MESSAGE_LATENCY => MessageView::Latency(Latency(self)), + ffi::GST_MESSAGE_ASYNC_START => MessageView::AsyncStart(AsyncStart(self)), + ffi::GST_MESSAGE_ASYNC_DONE => MessageView::AsyncDone(AsyncDone(self)), + ffi::GST_MESSAGE_REQUEST_STATE => MessageView::RequestState(RequestState(self)), + ffi::GST_MESSAGE_STEP_START => MessageView::StepStart(StepStart(self)), + ffi::GST_MESSAGE_QOS => MessageView::Qos(Qos(self)), + ffi::GST_MESSAGE_PROGRESS => MessageView::Progress(Progress(self)), + ffi::GST_MESSAGE_TOC => MessageView::Toc(Toc(self)), + ffi::GST_MESSAGE_RESET_TIME => MessageView::ResetTime(ResetTime(self)), + ffi::GST_MESSAGE_STREAM_START => MessageView::StreamStart(StreamStart(self)), + ffi::GST_MESSAGE_NEED_CONTEXT => MessageView::NeedContext(NeedContext(self)), + ffi::GST_MESSAGE_HAVE_CONTEXT => MessageView::HaveContext(HaveContext(self)), + ffi::GST_MESSAGE_DEVICE_ADDED => MessageView::DeviceAdded(DeviceAdded(self)), + ffi::GST_MESSAGE_DEVICE_REMOVED => MessageView::DeviceRemoved(DeviceRemoved(self)), + ffi::GST_MESSAGE_PROPERTY_NOTIFY => MessageView::PropertyNotify(PropertyNotify(self)), + ffi::GST_MESSAGE_STREAM_COLLECTION => { + MessageView::StreamCollection(StreamCollection(self)) + } + ffi::GST_MESSAGE_STREAMS_SELECTED => { + MessageView::StreamsSelected(StreamsSelected(self)) + } + _ => MessageView::Other, } } } @@ -1181,8 +1153,7 @@ pub struct ErrorBuilder<'a> { seqnum: Option, error: &'a glib::Error, debug: Option<&'a str>, - #[allow(unused)] - details: Option, + #[allow(unused)] details: Option, } impl<'a> ErrorBuilder<'a> { fn new(error: &'a glib::Error) -> Self { @@ -1242,8 +1213,7 @@ pub struct WarningBuilder<'a> { seqnum: Option, error: &'a glib::Error, debug: Option<&'a str>, - #[allow(unused)] - details: Option, + #[allow(unused)] details: Option, } impl<'a> WarningBuilder<'a> { fn new(error: &'a glib::Error) -> Self { @@ -1303,8 +1273,7 @@ pub struct InfoBuilder<'a> { seqnum: Option, error: &'a glib::Error, debug: Option<&'a str>, - #[allow(unused)] - details: Option, + #[allow(unused)] details: Option, } impl<'a> InfoBuilder<'a> { fn new(error: &'a glib::Error) -> Self { @@ -1877,13 +1846,7 @@ pub struct QosBuilder { stats: Option<(::Format, u64, u64)>, } impl QosBuilder { - fn new( - live: bool, - running_time: u64, - stream_time: u64, - timestamp: u64, - duration: u64, - ) -> Self { + fn new(live: bool, running_time: u64, stream_time: u64, timestamp: u64, duration: u64) -> Self { skip_assert_initialized!(); Self { src: None, @@ -2182,10 +2145,8 @@ impl<'a> StreamCollectionBuilder<'a> { pub struct StreamsSelectedBuilder<'a> { src: Option, seqnum: Option, - #[cfg(feature = "v1_10")] - collection: &'a ::StreamCollection, - #[cfg(feature = "v1_10")] - streams: Option<&'a [&'a ::Stream]>, + #[cfg(feature = "v1_10")] collection: &'a ::StreamCollection, + #[cfg(feature = "v1_10")] streams: Option<&'a [&'a ::Stream]>, } #[cfg(feature = "v1_10")] impl<'a> StreamsSelectedBuilder<'a> { @@ -2224,6 +2185,7 @@ pub struct RedirectBuilder<'a> { location: &'a str, tag_list: Option<&'a TagList>, entry_struct: Option, + #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] entries: Option<&'a [(&'a str, Option<&'a TagList>, Option<&'a Structure>)]>, } #[cfg(feature = "v1_10")] @@ -2271,7 +2233,7 @@ impl<'a> RedirectBuilder<'a> { ); if let Some(entries) = s.entries { for &(location, tag_list, entry_struct) in entries { - let entry_struct = entry_struct.map(|s| s.clone()); + let entry_struct = entry_struct.cloned(); let entry_struct_ptr = if let Some(entry_struct) = entry_struct { entry_struct.into_ptr() } else { diff --git a/gstreamer/src/miniobject.rs b/gstreamer/src/miniobject.rs index 4f9be07f1..a751e2d70 100644 --- a/gstreamer/src/miniobject.rs +++ b/gstreamer/src/miniobject.rs @@ -241,6 +241,7 @@ impl<'a, T: MiniObject + 'static> ToGlibPtrMut<'a, *mut T::GstType> for GstRc } impl<'a, T: MiniObject + 'static> ToGlibContainerFromSlice<'a, *mut *mut T::GstType> for GstRc { + #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] type Storage = (Vec>>, Option>); fn to_glib_none_from_slice(t: &'a [GstRc]) -> (*mut *mut T::GstType, Self::Storage) { @@ -284,6 +285,7 @@ impl<'a, T: MiniObject + 'static> ToGlibContainerFromSlice<'a, *mut *mut T::GstT } impl<'a, T: MiniObject + 'static> ToGlibContainerFromSlice<'a, *const *mut T::GstType> for GstRc { + #[cfg_attr(feature = "cargo-clippy", allow(type_complexity))] type Storage = (Vec>>, Option>); fn to_glib_none_from_slice(t: &'a [GstRc]) -> (*const *mut T::GstType, Self::Storage) { diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 95b4e0f0e..3f33df785 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -289,6 +289,7 @@ unsafe extern "C" fn trampoline_pad_probe( func: gpointer, ) -> ffi::GstPadProbeReturn { let _guard = CallbackGuard::new(); + #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] let func: &&(Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static) = transmute(func); let mut data_type = None; diff --git a/gstreamer/src/parse_context.rs b/gstreamer/src/parse_context.rs index d3921d2b7..3f36e31e3 100644 --- a/gstreamer/src/parse_context.rs +++ b/gstreamer/src/parse_context.rs @@ -43,3 +43,9 @@ impl ParseContext { } } } + +impl Default for ParseContext { + fn default() -> Self { + Self::new() + } +} diff --git a/gstreamer/src/query.rs b/gstreamer/src/query.rs index 42edcf3cb..55cb5e7a0 100644 --- a/gstreamer/src/query.rs +++ b/gstreamer/src/query.rs @@ -145,44 +145,26 @@ impl QueryRef { pub fn view(&self) -> QueryView<&Self> { let type_ = unsafe { (*self.as_ptr()).type_ }; - if type_ == ffi::GST_QUERY_POSITION { - QueryView::Position(Position(self)) - } else if type_ == ffi::GST_QUERY_DURATION { - QueryView::Duration(Duration(self)) - } else if type_ == ffi::GST_QUERY_LATENCY { - QueryView::Latency(Latency(self)) - } else if type_ == ffi::GST_QUERY_JITTER { - QueryView::Jitter(Jitter(self)) - } else if type_ == ffi::GST_QUERY_RATE { - QueryView::Rate(Rate(self)) - } else if type_ == ffi::GST_QUERY_SEEKING { - QueryView::Seeking(Seeking(self)) - } else if type_ == ffi::GST_QUERY_SEGMENT { - QueryView::Segment(Segment(self)) - } else if type_ == ffi::GST_QUERY_CONVERT { - QueryView::Convert(Convert(self)) - } else if type_ == ffi::GST_QUERY_FORMATS { - QueryView::Formats(Formats(self)) - } else if type_ == ffi::GST_QUERY_BUFFERING { - QueryView::Buffering(Buffering(self)) - } else if type_ == ffi::GST_QUERY_CUSTOM { - QueryView::Custom(Custom(self)) - } else if type_ == ffi::GST_QUERY_URI { - QueryView::Uri(Uri(self)) - } else if type_ == ffi::GST_QUERY_ALLOCATION { - QueryView::Allocation(Allocation(self)) - } else if type_ == ffi::GST_QUERY_SCHEDULING { - QueryView::Scheduling(Scheduling(self)) - } else if type_ == ffi::GST_QUERY_ACCEPT_CAPS { - QueryView::AcceptCaps(AcceptCaps(self)) - } else if type_ == ffi::GST_QUERY_CAPS { - QueryView::Caps(Caps(self)) - } else if type_ == ffi::GST_QUERY_DRAIN { - QueryView::Drain(Drain(self)) - } else if type_ == ffi::GST_QUERY_CONTEXT { - QueryView::Context(Context(self)) - } else { - QueryView::Other(Other(self)) + match type_ { + ffi::GST_QUERY_POSITION => QueryView::Position(Position(self)), + ffi::GST_QUERY_DURATION => QueryView::Duration(Duration(self)), + ffi::GST_QUERY_LATENCY => QueryView::Latency(Latency(self)), + ffi::GST_QUERY_JITTER => QueryView::Jitter(Jitter(self)), + ffi::GST_QUERY_RATE => QueryView::Rate(Rate(self)), + ffi::GST_QUERY_SEEKING => QueryView::Seeking(Seeking(self)), + ffi::GST_QUERY_SEGMENT => QueryView::Segment(Segment(self)), + ffi::GST_QUERY_CONVERT => QueryView::Convert(Convert(self)), + ffi::GST_QUERY_FORMATS => QueryView::Formats(Formats(self)), + ffi::GST_QUERY_BUFFERING => QueryView::Buffering(Buffering(self)), + ffi::GST_QUERY_CUSTOM => QueryView::Custom(Custom(self)), + ffi::GST_QUERY_URI => QueryView::Uri(Uri(self)), + ffi::GST_QUERY_ALLOCATION => QueryView::Allocation(Allocation(self)), + ffi::GST_QUERY_SCHEDULING => QueryView::Scheduling(Scheduling(self)), + ffi::GST_QUERY_ACCEPT_CAPS => QueryView::AcceptCaps(AcceptCaps(self)), + ffi::GST_QUERY_CAPS => QueryView::Caps(Caps(self)), + ffi::GST_QUERY_DRAIN => QueryView::Drain(Drain(self)), + ffi::GST_QUERY_CONTEXT => QueryView::Context(Context(self)), + _ => QueryView::Other(Other(self)), } } diff --git a/gstreamer/src/segment.rs b/gstreamer/src/segment.rs index 963525988..385503df4 100644 --- a/gstreamer/src/segment.rs +++ b/gstreamer/src/segment.rs @@ -51,6 +51,7 @@ impl Segment { } } + #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] pub fn do_seek( &mut self, rate: f64, @@ -320,6 +321,12 @@ impl glib::types::StaticType for Segment { } } +impl Default for Segment { + fn default() -> Self { + Self::new() + } +} + #[doc(hidden)] impl<'a> glib::value::FromValueOptional<'a> for Segment { unsafe fn from_value_optional(value: &glib::Value) -> Option { diff --git a/gstreamer/src/tags.rs b/gstreamer/src/tags.rs index b831e63e8..54dfc65d7 100644 --- a/gstreamer/src/tags.rs +++ b/gstreamer/src/tags.rs @@ -244,6 +244,12 @@ impl GstRc { } } +impl Default for GstRc { + fn default() -> Self { + Self::new() + } +} + impl TagListRef { pub fn add<'a, T: Tag<'a>>(&mut self, value: T::TagType, mode: TagMergeMode) where