diff --git a/gstreamer/src/buffer_serde.rs b/gstreamer/src/buffer_serde.rs index 2b3becc3b..cbf40466a 100644 --- a/gstreamer/src/buffer_serde.rs +++ b/gstreamer/src/buffer_serde.rs @@ -13,7 +13,7 @@ use crate::ClockTime; // TODO: try `Either` to merge the base reprensentations for ser and de // while avoiding unneeded copy -impl<'a> Serialize for BufferRef { +impl Serialize for BufferRef { fn serialize(&self, serializer: S) -> Result { let mut buffer = serializer.serialize_struct("Buffer", 6)?; buffer.serialize_field("pts", &self.pts())?; @@ -32,7 +32,7 @@ impl<'a> Serialize for BufferRef { } } -impl<'a> Serialize for Buffer { +impl Serialize for Buffer { fn serialize(&self, serializer: S) -> Result { self.as_ref().serialize(serializer) } diff --git a/gstreamer/src/clock_time_serde.rs b/gstreamer/src/clock_time_serde.rs index 4f83d7b8d..65d8e3301 100644 --- a/gstreamer/src/clock_time_serde.rs +++ b/gstreamer/src/clock_time_serde.rs @@ -5,7 +5,7 @@ use serde::ser::{Serialize, Serializer}; use crate::ClockTime; -impl<'a> Serialize for ClockTime { +impl Serialize for ClockTime { fn serialize(&self, serializer: S) -> Result { self.0.serialize(serializer) } diff --git a/gstreamer/src/date_time_serde.rs b/gstreamer/src/date_time_serde.rs index 89d3281e5..f21ae10cc 100644 --- a/gstreamer/src/date_time_serde.rs +++ b/gstreamer/src/date_time_serde.rs @@ -56,7 +56,7 @@ impl StaticType for Date { } } -impl<'a> Serialize for Date { +impl Serialize for Date { fn serialize(&self, serializer: S) -> Result { DateTimeVariants::YMD( self.0.year() as i32, @@ -67,7 +67,7 @@ impl<'a> Serialize for Date { } } -impl<'a> Serialize for DateTime { +impl Serialize for DateTime { fn serialize(&self, serializer: S) -> Result { let variant = if self.has_second() { DateTimeVariants::YMDhmsTz( diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index e85690fc6..d921e8b62 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -32,6 +32,7 @@ macro_rules! skip_assert_initialized { #[allow(clippy::type_complexity)] #[allow(clippy::use_self)] #[allow(clippy::needless_borrow)] +#[allow(clippy::let_unit_value)] #[allow(unused_imports)] mod auto; pub use crate::auto::functions::*; diff --git a/gstreamer/src/sample_serde.rs b/gstreamer/src/sample_serde.rs index 88c378269..ab2b5bfcf 100644 --- a/gstreamer/src/sample_serde.rs +++ b/gstreamer/src/sample_serde.rs @@ -11,7 +11,7 @@ use crate::SampleRef; use crate::Segment; use crate::Structure; -impl<'a> Serialize for SampleRef { +impl Serialize for SampleRef { fn serialize(&self, serializer: S) -> Result { let mut sample = serializer.serialize_struct("Sample", 5)?; sample.serialize_field("buffer", &self.buffer())?; @@ -23,7 +23,7 @@ impl<'a> Serialize for SampleRef { } } -impl<'a> Serialize for Sample { +impl Serialize for Sample { fn serialize(&self, serializer: S) -> Result { self.as_ref().serialize(serializer) } diff --git a/gstreamer/src/typefind.rs b/gstreamer/src/typefind.rs index 7e6300f69..55c88c705 100644 --- a/gstreamer/src/typefind.rs +++ b/gstreamer/src/typefind.rs @@ -206,18 +206,20 @@ impl> TypeFindImpl for SliceTypeFind { let len = data.len(); let offset = if offset >= 0 { - offset as usize + usize::try_from(offset).ok()? } else { - if len < offset.abs() as usize { + let offset = usize::try_from(offset.unsigned_abs()).ok()?; + if len < offset { return None; } - len - (offset.abs() as usize) + len - offset }; - let size = size as usize; - if offset + size <= len { - Some(&data[offset..(offset + size)]) + let size = usize::try_from(size).ok()?; + let end_offset = offset.checked_add(size)?; + if end_offset <= len { + Some(&data[offset..end_offset]) } else { None }