Fix / silence various new Rust 1.83 clippy warnings

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1954>
This commit is contained in:
Sebastian Dröge 2024-11-29 17:57:44 +02:00
parent 9e59efd9d6
commit 6aeb3f2af2
26 changed files with 43 additions and 51 deletions

View file

@ -77,7 +77,7 @@ impl<'a> Iterator for RingBufferIter<'a> {
} }
} }
impl<'a> Drop for RingBufferIter<'a> { impl Drop for RingBufferIter<'_> {
fn drop(&mut self) { fn drop(&mut self) {
*self.buffer_pos = self.write_pos; *self.buffer_pos = self.write_pos;
} }

View file

@ -90,7 +90,7 @@ mod imp {
pub(super) fn original_buffer_meta_api_get_type() -> glib::Type { pub(super) fn original_buffer_meta_api_get_type() -> glib::Type {
static TYPE: LazyLock<glib::Type> = LazyLock::new(|| unsafe { static TYPE: LazyLock<glib::Type> = LazyLock::new(|| unsafe {
let t = from_glib(gst::ffi::gst_meta_api_type_register( let t = from_glib(gst::ffi::gst_meta_api_type_register(
b"GstOriginalBufferMetaAPI\0".as_ptr() as *const _, c"GstOriginalBufferMetaAPI".as_ptr() as *const _,
[ptr::null::<std::os::raw::c_char>()].as_ptr() as *mut *const _, [ptr::null::<std::os::raw::c_char>()].as_ptr() as *mut *const _,
)); ));
@ -161,7 +161,7 @@ mod imp {
MetaInfo( MetaInfo(
ptr::NonNull::new(gst::ffi::gst_meta_register( ptr::NonNull::new(gst::ffi::gst_meta_register(
original_buffer_meta_api_get_type().into_glib(), original_buffer_meta_api_get_type().into_glib(),
b"OriginalBufferMeta\0".as_ptr() as *const _, c"OriginalBufferMeta".as_ptr() as *const _,
mem::size_of::<OriginalBufferMeta>(), mem::size_of::<OriginalBufferMeta>(),
Some(original_buffer_meta_init), Some(original_buffer_meta_init),
Some(original_buffer_meta_free), Some(original_buffer_meta_free),

View file

@ -303,7 +303,7 @@ impl Encrypter {
}; };
// calculate the number of chunks that exist in the stream // calculate the number of chunks that exist in the stream
let total_chunks = (size + state.block_size as u64 - 1) / state.block_size as u64; let total_chunks = size.div_ceil(state.block_size as u64);
// add the MAC of each block // add the MAC of each block
let size = size + total_chunks * box_::MACBYTES as u64; let size = size + total_chunks * box_::MACBYTES as u64;

View file

@ -65,10 +65,8 @@ impl State {
use std::collections::btree_map::Entry::{Occupied, Vacant}; use std::collections::btree_map::Entry::{Occupied, Vacant};
match self.streams_by_number.entry(number) { match self.streams_by_number.entry(number) {
Occupied(_) => panic!("Stream {number} already exists!"), Occupied(_) => panic!("Stream {number} already exists!"),
Vacant(entry) => { Vacant(entry) => entry.insert(stream),
return entry.insert(stream);
} }
};
} }
fn remove_stream_or_panic(&mut self, number: usize) { fn remove_stream_or_panic(&mut self, number: usize) {

View file

@ -6,13 +6,11 @@
//! A collection of GStreamer plugins which leverage the `threadshare` [`runtime`]. //! A collection of GStreamer plugins which leverage the `threadshare` [`runtime`].
//! //!
//! [`runtime`]: runtime/index.html //! [`runtime`]: runtime/index.html
/** /**
* plugin-threadshare: * plugin-threadshare:
* *
* Since: plugins-rs-0.4.0 * Since: plugins-rs-0.4.0
*/ */
#[macro_use] #[macro_use]
pub mod runtime; pub mod runtime;

View file

@ -318,7 +318,7 @@ pub struct PadSrcRef<'a> {
phantom: PhantomData<&'a Self>, phantom: PhantomData<&'a Self>,
} }
impl<'a> PadSrcRef<'a> { impl PadSrcRef<'_> {
fn new(inner_arc: Arc<PadSrcInner>) -> Self { fn new(inner_arc: Arc<PadSrcInner>) -> Self {
PadSrcRef { PadSrcRef {
strong: inner_arc, strong: inner_arc,
@ -331,7 +331,7 @@ impl<'a> PadSrcRef<'a> {
} }
} }
impl<'a> Deref for PadSrcRef<'a> { impl Deref for PadSrcRef<'_> {
type Target = PadSrcInner; type Target = PadSrcInner;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
@ -712,7 +712,7 @@ pub struct PadSinkRef<'a> {
phantom: PhantomData<&'a Self>, phantom: PhantomData<&'a Self>,
} }
impl<'a> PadSinkRef<'a> { impl PadSinkRef<'_> {
fn new(inner_arc: Arc<PadSinkInner>) -> Self { fn new(inner_arc: Arc<PadSinkInner>) -> Self {
PadSinkRef { PadSinkRef {
strong: inner_arc, strong: inner_arc,
@ -725,7 +725,7 @@ impl<'a> PadSinkRef<'a> {
} }
} }
impl<'a> Deref for PadSinkRef<'a> { impl Deref for PadSinkRef<'_> {
type Target = PadSinkInner; type Target = PadSinkInner;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {

View file

@ -1324,10 +1324,10 @@ impl FMP4Mux {
let fragment_end_pts = fragment_start_pts + settings.fragment_duration; let fragment_end_pts = fragment_start_pts + settings.fragment_duration;
// If we have a manual fragment boundary set then use that // If we have a manual fragment boundary set then use that
return *manual_fragment_boundaries *manual_fragment_boundaries
.range((Excluded(fragment_start_pts), Excluded(fragment_end_pts))) .range((Excluded(fragment_start_pts), Excluded(fragment_end_pts)))
.next() .next()
.unwrap_or(&fragment_end_pts); .unwrap_or(&fragment_end_pts)
} }
/// Check if the stream is filled enough for the current chunk / fragment. /// Check if the stream is filled enough for the current chunk / fragment.

View file

@ -6,7 +6,6 @@
* *
* Since: plugins-rs-0.9 * Since: plugins-rs-0.9
*/ */
#[allow(dead_code)] #[allow(dead_code)]
mod ndi; mod ndi;
#[allow(dead_code)] #[allow(dead_code)]

View file

@ -23,7 +23,7 @@ pub struct FindBuilder<'a> {
extra_ips: Option<&'a str>, extra_ips: Option<&'a str>,
} }
impl<'a> Default for FindBuilder<'a> { impl Default for FindBuilder<'_> {
fn default() -> Self { fn default() -> Self {
Self { Self {
show_local_sources: true, show_local_sources: true,
@ -129,10 +129,10 @@ pub enum Source<'a> {
Owned(NDIlib_source_t, ffi::CString, ffi::CString), Owned(NDIlib_source_t, ffi::CString, ffi::CString),
} }
unsafe impl<'a> Send for Source<'a> {} unsafe impl Send for Source<'_> {}
unsafe impl<'a> Sync for Source<'a> {} unsafe impl Sync for Source<'_> {}
impl<'a> Source<'a> { impl Source<'_> {
pub fn ndi_name(&self) -> &str { pub fn ndi_name(&self) -> &str {
unsafe { unsafe {
let ptr = match *self { let ptr = match *self {
@ -198,7 +198,7 @@ pub struct RecvBuilder<'a> {
ndi_recv_name: &'a str, ndi_recv_name: &'a str,
} }
impl<'a> RecvBuilder<'a> { impl RecvBuilder<'_> {
pub fn allow_video_fields(self, allow_video_fields: bool) -> Self { pub fn allow_video_fields(self, allow_video_fields: bool) -> Self {
Self { Self {
allow_video_fields, allow_video_fields,
@ -362,7 +362,7 @@ pub struct SendBuilder<'a> {
clock_video: bool, clock_video: bool,
} }
impl<'a> SendBuilder<'a> { impl SendBuilder<'_> {
pub fn clock_audio(self) -> Self { pub fn clock_audio(self) -> Self {
Self { Self {
clock_audio: true, clock_audio: true,

View file

@ -70,7 +70,7 @@ mod imp {
pub(super) fn ndi_sink_audio_meta_api_get_type() -> glib::Type { pub(super) fn ndi_sink_audio_meta_api_get_type() -> glib::Type {
static TYPE: LazyLock<glib::Type> = LazyLock::new(|| unsafe { static TYPE: LazyLock<glib::Type> = LazyLock::new(|| unsafe {
let t = from_glib(gst::ffi::gst_meta_api_type_register( let t = from_glib(gst::ffi::gst_meta_api_type_register(
b"GstNdiSinkAudioMetaAPI\0".as_ptr() as *const _, c"GstNdiSinkAudioMetaAPI".as_ptr() as *const _,
[ptr::null::<std::os::raw::c_char>()].as_ptr() as *mut *const _, [ptr::null::<std::os::raw::c_char>()].as_ptr() as *mut *const _,
)); ));
@ -129,7 +129,7 @@ mod imp {
MetaInfo( MetaInfo(
ptr::NonNull::new(gst::ffi::gst_meta_register( ptr::NonNull::new(gst::ffi::gst_meta_register(
ndi_sink_audio_meta_api_get_type().into_glib(), ndi_sink_audio_meta_api_get_type().into_glib(),
b"GstNdiSinkAudioMeta\0".as_ptr() as *const _, c"GstNdiSinkAudioMeta".as_ptr() as *const _,
mem::size_of::<NdiSinkAudioMeta>(), mem::size_of::<NdiSinkAudioMeta>(),
Some(ndi_sink_audio_meta_init), Some(ndi_sink_audio_meta_init),
Some(ndi_sink_audio_meta_free), Some(ndi_sink_audio_meta_free),

View file

@ -95,7 +95,7 @@ mod imp {
pub(super) fn ndi_src_meta_api_get_type() -> glib::Type { pub(super) fn ndi_src_meta_api_get_type() -> glib::Type {
static TYPE: LazyLock<glib::Type> = LazyLock::new(|| unsafe { static TYPE: LazyLock<glib::Type> = LazyLock::new(|| unsafe {
let t = from_glib(gst::ffi::gst_meta_api_type_register( let t = from_glib(gst::ffi::gst_meta_api_type_register(
b"GstNdiSrcMetaAPI\0".as_ptr() as *const _, c"GstNdiSrcMetaAPI".as_ptr() as *const _,
[ptr::null::<std::os::raw::c_char>()].as_ptr() as *mut *const _, [ptr::null::<std::os::raw::c_char>()].as_ptr() as *mut *const _,
)); ));
@ -150,7 +150,7 @@ mod imp {
MetaInfo( MetaInfo(
ptr::NonNull::new(gst::ffi::gst_meta_register( ptr::NonNull::new(gst::ffi::gst_meta_register(
ndi_src_meta_api_get_type().into_glib(), ndi_src_meta_api_get_type().into_glib(),
b"GstNdiSrcMeta\0".as_ptr() as *const _, c"GstNdiSrcMeta".as_ptr() as *const _,
mem::size_of::<NdiSrcMeta>(), mem::size_of::<NdiSrcMeta>(),
Some(ndi_src_meta_init), Some(ndi_src_meta_init),
Some(ndi_src_meta_free), Some(ndi_src_meta_free),

View file

@ -81,7 +81,7 @@ mod imp {
*TYPE.get_or_init(|| unsafe { *TYPE.get_or_init(|| unsafe {
let t = glib::Type::from_glib(gst::ffi::gst_meta_api_type_register( let t = glib::Type::from_glib(gst::ffi::gst_meta_api_type_register(
b"QuinnQuicMetaAPI\0".as_ptr() as *const _, c"QuinnQuicMetaAPI".as_ptr() as *const _,
[ptr::null::<std::os::raw::c_int>()].as_ptr() as *mut *const _, [ptr::null::<std::os::raw::c_int>()].as_ptr() as *mut *const _,
)); ));
@ -147,7 +147,7 @@ mod imp {
MetaInfo( MetaInfo(
ptr::NonNull::new(gst::ffi::gst_meta_register( ptr::NonNull::new(gst::ffi::gst_meta_register(
custom_meta_api_get_type().into_glib(), custom_meta_api_get_type().into_glib(),
b"QuinnQuicMeta\0".as_ptr() as *const _, c"QuinnQuicMeta".as_ptr() as *const _,
mem::size_of::<QuinnQuicMeta>(), mem::size_of::<QuinnQuicMeta>(),
Some(custom_meta_init), Some(custom_meta_init),
Some(custom_meta_free), Some(custom_meta_free),

View file

@ -576,7 +576,7 @@ impl RaptorqEnc {
// it SHALL be the same for all repair packets in a block. This include // it SHALL be the same for all repair packets in a block. This include
// 1 byte of flow indication and 2 bytes of length indication as defined // 1 byte of flow indication and 2 bytes of length indication as defined
// in RFC6881, section 8.2.4. // in RFC6881, section 8.2.4.
let symbols_per_packet = (mtu + 3 + symbol_size - 1) / symbol_size; let symbols_per_packet = (mtu + 3).div_ceil(symbol_size);
let symbols_per_block = symbols_per_packet * protected_packets_num; let symbols_per_block = symbols_per_packet * protected_packets_num;
if symbol_size.rem_euclid(SYMBOL_ALIGNMENT) != 0 { if symbol_size.rem_euclid(SYMBOL_ALIGNMENT) != 0 {

View file

@ -530,7 +530,7 @@ impl RtpAc3Pay {
}; };
// The number fragments (and therefore packets) that make up the current frame // The number fragments (and therefore packets) that make up the current frame
let n = (first.header.frame_len + max_payload_size - 1) / max_payload_size; let n = first.header.frame_len.div_ceil(max_payload_size);
let ac3_specific_header = ((frame_type << 8) | (n as u16)).to_be_bytes(); let ac3_specific_header = ((frame_type << 8) | (n as u16)).to_be_bytes();

View file

@ -151,7 +151,7 @@ impl FromByteStream for RestartHeader {
} }
} }
impl<'a> ToByteStreamWith<'a> for RestartHeader { impl ToByteStreamWith<'_> for RestartHeader {
type Error = anyhow::Error; type Error = anyhow::Error;
type Context = MainHeader; type Context = MainHeader;
@ -216,7 +216,7 @@ impl Default for QuantizationTableHeader {
} }
} }
impl<'a> FromByteStreamWith<'a> for QuantizationTableHeader { impl FromByteStreamWith<'_> for QuantizationTableHeader {
type Error = anyhow::Error; type Error = anyhow::Error;
type Context = MainHeader; type Context = MainHeader;
@ -267,7 +267,7 @@ impl<'a> FromByteStreamWith<'a> for QuantizationTableHeader {
} }
} }
impl<'a> ToByteStreamWith<'a> for QuantizationTableHeader { impl ToByteStreamWith<'_> for QuantizationTableHeader {
type Error = anyhow::Error; type Error = anyhow::Error;
type Context = MainHeader; type Context = MainHeader;

View file

@ -14,7 +14,6 @@
* *
* Since: plugins-rs-0.9.0 * Since: plugins-rs-0.9.0
*/ */
#[macro_use] #[macro_use]
extern crate log; extern crate log;

View file

@ -265,7 +265,7 @@ impl<'a> Subframes<'a> {
} }
} }
impl<'a> Iterator for Subframes<'a> { impl Iterator for Subframes<'_> {
type Item = Result<gst::Buffer, MPEG4AudioParserError>; type Item = Result<gst::Buffer, MPEG4AudioParserError>;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {

View file

@ -159,7 +159,7 @@ pub struct AccessUnitIter<'a> {
cur: u32, cur: u32,
} }
impl<'a> Iterator for AccessUnitIter<'a> { impl Iterator for AccessUnitIter<'_> {
type Item = anyhow::Result<AccessUnit>; type Item = anyhow::Result<AccessUnit>;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
@ -172,7 +172,7 @@ impl<'a> Iterator for AccessUnitIter<'a> {
} }
} }
impl<'a> AccessUnitIter<'a> { impl AccessUnitIter<'_> {
fn next_priv(&mut self) -> Option<anyhow::Result<AccessUnit>> { fn next_priv(&mut self) -> Option<anyhow::Result<AccessUnit>> {
use Mpeg4GenericDepayError::*; use Mpeg4GenericDepayError::*;

View file

@ -240,7 +240,7 @@ fn generic_fragmented() {
const BUFFER_SIZE: usize = 2000; const BUFFER_SIZE: usize = 2000;
const MTU: usize = 1400; const MTU: usize = 1400;
// Enough overhead in the MTU to use this approximation: // Enough overhead in the MTU to use this approximation:
const FRAGMENTS_PER_BUFFER: usize = (BUFFER_SIZE + MTU - 1) / MTU; const FRAGMENTS_PER_BUFFER: usize = BUFFER_SIZE.div_ceil(MTU);
const RTP_CLOCK_RATE: u64 = 90_000; const RTP_CLOCK_RATE: u64 = 90_000;
const LAST_FRAGMENT: usize = FRAGMENTS_PER_BUFFER - 1; const LAST_FRAGMENT: usize = FRAGMENTS_PER_BUFFER - 1;
const FRAME_RATE: u64 = 30; const FRAME_RATE: u64 = 30;
@ -357,7 +357,7 @@ fn generic_variable_au_size() {
const AU_NB: usize = 5; const AU_NB: usize = 5;
const SMALL_AU_SIZE: usize = 500; const SMALL_AU_SIZE: usize = 500;
const LARGE_AU_SIZE: usize = 2000; const LARGE_AU_SIZE: usize = 2000;
const FRAGMENTS_PER_LARGE_BUFFER: usize = (LARGE_AU_SIZE + MTU - 1) / MTU; const FRAGMENTS_PER_LARGE_BUFFER: usize = LARGE_AU_SIZE.div_ceil(MTU);
const LAST_FRAGMENT: usize = FRAGMENTS_PER_LARGE_BUFFER - 1; const LAST_FRAGMENT: usize = FRAGMENTS_PER_LARGE_BUFFER - 1;
const RTP_CLOCK_RATE: u64 = 90_000; const RTP_CLOCK_RATE: u64 = 90_000;
const FRAME_RATE: u64 = 30; const FRAME_RATE: u64 = 30;

View file

@ -70,7 +70,7 @@ impl Rb {
} }
} }
impl<'a> From<ReportBlock<'a>> for Rb { impl From<ReportBlock<'_>> for Rb {
fn from(value: ReportBlock) -> Self { fn from(value: ReportBlock) -> Self {
Self { Self {
ssrc: value.ssrc(), ssrc: value.ssrc(),

View file

@ -117,7 +117,7 @@ trait BitReadExt: BitRead {
impl<T: BitRead + ?Sized> BitReadExt for T {} impl<T: BitRead + ?Sized> BitReadExt for T {}
impl<'a> FromBitStreamWith<'a> for FrameHeader { impl FromBitStreamWith<'_> for FrameHeader {
type Error = anyhow::Error; type Error = anyhow::Error;
/// Keyframe? /// Keyframe?
type Context = bool; type Context = bool;

View file

@ -98,7 +98,7 @@ pub struct KeyframeInfo {
pub render_size: Option<(u32, u32)>, pub render_size: Option<(u32, u32)>,
} }
impl<'a> FromBitStreamWith<'a> for KeyframeInfo { impl FromBitStreamWith<'_> for KeyframeInfo {
type Error = anyhow::Error; type Error = anyhow::Error;
/// Profile /// Profile
@ -173,7 +173,7 @@ pub struct ColorConfig {
pub sub_sampling_y: u8, pub sub_sampling_y: u8,
} }
impl<'a> FromBitStreamWith<'a> for ColorConfig { impl FromBitStreamWith<'_> for ColorConfig {
type Error = anyhow::Error; type Error = anyhow::Error;
/// Profile /// Profile

View file

@ -310,7 +310,7 @@ pub struct LayerIndex {
pub temporal_layer_zero_index: Option<u8>, pub temporal_layer_zero_index: Option<u8>,
} }
impl<'a> FromByteStreamWith<'a> for LayerIndex { impl FromByteStreamWith<'_> for LayerIndex {
type Error = anyhow::Error; type Error = anyhow::Error;
/// Flexible mode? /// Flexible mode?
type Context = bool; type Context = bool;
@ -345,7 +345,7 @@ impl<'a> FromByteStreamWith<'a> for LayerIndex {
} }
} }
impl<'a> ToByteStreamWith<'a> for LayerIndex { impl ToByteStreamWith<'_> for LayerIndex {
type Error = anyhow::Error; type Error = anyhow::Error;
/// Flexible mode? /// Flexible mode?

View file

@ -18,14 +18,12 @@ use crate::signaller::Signallable;
* See the [documentation of the plugin](plugin-rswebrtc) for more information * See the [documentation of the plugin](plugin-rswebrtc) for more information
* on features and usage. * on features and usage.
*/ */
/** /**
* GstBaseWebRTCSink: * GstBaseWebRTCSink:
* @title: Base class for WebRTC producers * @title: Base class for WebRTC producers
* *
* Base class for WebRTC sinks to implement and provide their own protocol for. * Base class for WebRTC sinks to implement and provide their own protocol for.
*/ */
/** /**
* GstRSWebRTCSignallableIface: * GstRSWebRTCSignallableIface:
* @title: Interface for WebRTC signalling protocols * @title: Interface for WebRTC signalling protocols

View file

@ -604,7 +604,7 @@ impl Dav1dDec {
&'s self, &'s self,
mut state_guard: MutexGuard<'s, Option<State>>, mut state_guard: MutexGuard<'s, Option<State>>,
drain: bool, drain: bool,
) -> Result<MutexGuard<Option<State>>, gst::FlowError> { ) -> Result<MutexGuard<'s, Option<State>>, gst::FlowError> {
// dav1d wants to have get_picture() called a second time after it return EAGAIN to // dav1d wants to have get_picture() called a second time after it return EAGAIN to
// actually drain all pending pictures. // actually drain all pending pictures.
let mut call_twice = drain; let mut call_twice = drain;

View file

@ -47,8 +47,8 @@ struct Info {
frame_count: u32, frame_count: u32,
} }
impl<'a> Decoder<'_> { impl Decoder<'_> {
fn from_data(data: &'a [u8]) -> Option<Self> { fn from_data(data: &[u8]) -> Option<Self> {
unsafe { unsafe {
let mut options = std::mem::MaybeUninit::zeroed(); let mut options = std::mem::MaybeUninit::zeroed();
if ffi::WebPAnimDecoderOptionsInit(options.as_mut_ptr()) == 0 { if ffi::WebPAnimDecoderOptionsInit(options.as_mut_ptr()) == 0 {