forked from mirrors/gstreamer-rs
gstreamer: Fix a few new clippy warnings
This commit is contained in:
parent
0055399471
commit
e76ae3f434
6 changed files with 16 additions and 13 deletions
|
@ -13,7 +13,7 @@ use crate::ClockTime;
|
||||||
// TODO: try `Either<ByteBuf, Bytes>` to merge the base reprensentations for ser and de
|
// TODO: try `Either<ByteBuf, Bytes>` to merge the base reprensentations for ser and de
|
||||||
// while avoiding unneeded copy
|
// while avoiding unneeded copy
|
||||||
|
|
||||||
impl<'a> Serialize for BufferRef {
|
impl Serialize for BufferRef {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
let mut buffer = serializer.serialize_struct("Buffer", 6)?;
|
let mut buffer = serializer.serialize_struct("Buffer", 6)?;
|
||||||
buffer.serialize_field("pts", &self.pts())?;
|
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<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
self.as_ref().serialize(serializer)
|
self.as_ref().serialize(serializer)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use serde::ser::{Serialize, Serializer};
|
||||||
|
|
||||||
use crate::ClockTime;
|
use crate::ClockTime;
|
||||||
|
|
||||||
impl<'a> Serialize for ClockTime {
|
impl Serialize for ClockTime {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
self.0.serialize(serializer)
|
self.0.serialize(serializer)
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ impl StaticType for Date {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Serialize for Date {
|
impl Serialize for Date {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
DateTimeVariants::YMD(
|
DateTimeVariants::YMD(
|
||||||
self.0.year() as i32,
|
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<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
let variant = if self.has_second() {
|
let variant = if self.has_second() {
|
||||||
DateTimeVariants::YMDhmsTz(
|
DateTimeVariants::YMDhmsTz(
|
||||||
|
|
|
@ -32,6 +32,7 @@ macro_rules! skip_assert_initialized {
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
#[allow(clippy::use_self)]
|
#[allow(clippy::use_self)]
|
||||||
#[allow(clippy::needless_borrow)]
|
#[allow(clippy::needless_borrow)]
|
||||||
|
#[allow(clippy::let_unit_value)]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
mod auto;
|
mod auto;
|
||||||
pub use crate::auto::functions::*;
|
pub use crate::auto::functions::*;
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::SampleRef;
|
||||||
use crate::Segment;
|
use crate::Segment;
|
||||||
use crate::Structure;
|
use crate::Structure;
|
||||||
|
|
||||||
impl<'a> Serialize for SampleRef {
|
impl Serialize for SampleRef {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
let mut sample = serializer.serialize_struct("Sample", 5)?;
|
let mut sample = serializer.serialize_struct("Sample", 5)?;
|
||||||
sample.serialize_field("buffer", &self.buffer())?;
|
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<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
self.as_ref().serialize(serializer)
|
self.as_ref().serialize(serializer)
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,18 +206,20 @@ impl<T: AsRef<[u8]>> TypeFindImpl for SliceTypeFind<T> {
|
||||||
let len = data.len();
|
let len = data.len();
|
||||||
|
|
||||||
let offset = if offset >= 0 {
|
let offset = if offset >= 0 {
|
||||||
offset as usize
|
usize::try_from(offset).ok()?
|
||||||
} else {
|
} else {
|
||||||
if len < offset.abs() as usize {
|
let offset = usize::try_from(offset.unsigned_abs()).ok()?;
|
||||||
|
if len < offset {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
len - (offset.abs() as usize)
|
len - offset
|
||||||
};
|
};
|
||||||
|
|
||||||
let size = size as usize;
|
let size = usize::try_from(size).ok()?;
|
||||||
if offset + size <= len {
|
let end_offset = offset.checked_add(size)?;
|
||||||
Some(&data[offset..(offset + size)])
|
if end_offset <= len {
|
||||||
|
Some(&data[offset..end_offset])
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue