Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix clippy and fmt
Browse files Browse the repository at this point in the history
yngrtc committed Jan 26, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 0aa7c07 commit 761d70d
Showing 28 changed files with 28 additions and 84 deletions.
2 changes: 1 addition & 1 deletion dtls/src/extension/extension_server_name.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ impl ExtensionServerName {

pub fn size(&self) -> usize {
//TODO: check how to do cryptobyte?
2 + 2 + 1 + 2 + self.server_name.as_bytes().len()
2 + 2 + 1 + 2 + self.server_name.len()
}

pub fn marshal<W: Write>(&self, writer: &mut W) -> Result<()> {
2 changes: 1 addition & 1 deletion ice/src/agent/agent_internal.rs
Original file line number Diff line number Diff line change
@@ -984,7 +984,7 @@ impl AgentInternal {
) -> bool {
self.find_remote_candidate(local.network_type(), remote)
.await
.map_or(false, |remote_candidate| {
.is_some_and(|remote_candidate| {
remote_candidate.seen(false);
true
})
2 changes: 1 addition & 1 deletion mdns/src/message/resource/txt.rs
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ impl ResourceBody for TxtResource {
let (t, new_off) = unpack_str(msg, off)?;
off = new_off;
// Check if we got too many bytes.
if length < n + t.as_bytes().len() + 1 {
if length < n + t.len() + 1 {
return Err(Error::ErrCalcLen);
}
n += t.len() + 1;
5 changes: 1 addition & 4 deletions rtcp/src/compound_packet/mod.rs
Original file line number Diff line number Diff line change
@@ -66,10 +66,7 @@ impl Packet for CompoundPacket {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<CompoundPacket>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<CompoundPacket>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/extended_report/dlrr.rs
Original file line number Diff line number Diff line change
@@ -77,10 +77,7 @@ impl Packet for DLRRReportBlock {
self
}
fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<DLRRReportBlock>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<DLRRReportBlock>() == Some(self)
}
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
Box::new(self.clone())
5 changes: 1 addition & 4 deletions rtcp/src/extended_report/mod.rs
Original file line number Diff line number Diff line change
@@ -199,10 +199,7 @@ impl Packet for ExtendedReport {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<ExtendedReport>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<ExtendedReport>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
2 changes: 1 addition & 1 deletion rtcp/src/extended_report/prt.rs
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ impl Packet for PacketReceiptTimesReportBlock {
other
.as_any()
.downcast_ref::<PacketReceiptTimesReportBlock>()
.map_or(false, |a| self == a)
== Some(self)
}
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
Box::new(self.clone())
5 changes: 1 addition & 4 deletions rtcp/src/extended_report/rle.rs
Original file line number Diff line number Diff line change
@@ -163,10 +163,7 @@ impl Packet for RLEReportBlock {
self
}
fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<RLEReportBlock>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<RLEReportBlock>() == Some(self)
}
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
Box::new(self.clone())
2 changes: 1 addition & 1 deletion rtcp/src/extended_report/rrt.rs
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ impl Packet for ReceiverReferenceTimeReportBlock {
other
.as_any()
.downcast_ref::<ReceiverReferenceTimeReportBlock>()
.map_or(false, |a| self == a)
== Some(self)
}
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
Box::new(self.clone())
2 changes: 1 addition & 1 deletion rtcp/src/extended_report/ssr.rs
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ impl Packet for StatisticsSummaryReportBlock {
other
.as_any()
.downcast_ref::<StatisticsSummaryReportBlock>()
.map_or(false, |a| self == a)
== Some(self)
}
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
Box::new(self.clone())
5 changes: 1 addition & 4 deletions rtcp/src/extended_report/unknown.rs
Original file line number Diff line number Diff line change
@@ -41,10 +41,7 @@ impl Packet for UnknownReportBlock {
self
}
fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<UnknownReportBlock>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<UnknownReportBlock>() == Some(self)
}
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
Box::new(self.clone())
5 changes: 1 addition & 4 deletions rtcp/src/extended_report/vm.rs
Original file line number Diff line number Diff line change
@@ -86,10 +86,7 @@ impl Packet for VoIPMetricsReportBlock {
self
}
fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<VoIPMetricsReportBlock>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<VoIPMetricsReportBlock>() == Some(self)
}
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
Box::new(self.clone())
5 changes: 1 addition & 4 deletions rtcp/src/goodbye/mod.rs
Original file line number Diff line number Diff line change
@@ -63,10 +63,7 @@ impl Packet for Goodbye {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<Goodbye>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<Goodbye>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/payload_feedbacks/full_intra_request/mod.rs
Original file line number Diff line number Diff line change
@@ -71,10 +71,7 @@ impl Packet for FullIntraRequest {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<FullIntraRequest>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<FullIntraRequest>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/payload_feedbacks/picture_loss_indication/mod.rs
Original file line number Diff line number Diff line change
@@ -60,10 +60,7 @@ impl Packet for PictureLossIndication {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<PictureLossIndication>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<PictureLossIndication>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ impl Packet for ReceiverEstimatedMaximumBitrate {
other
.as_any()
.downcast_ref::<ReceiverEstimatedMaximumBitrate>()
.map_or(false, |a| self == a)
== Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/payload_feedbacks/slice_loss_indication/mod.rs
Original file line number Diff line number Diff line change
@@ -75,10 +75,7 @@ impl Packet for SliceLossIndication {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<SliceLossIndication>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<SliceLossIndication>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/raw_packet.rs
Original file line number Diff line number Diff line change
@@ -40,10 +40,7 @@ impl Packet for RawPacket {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<RawPacket>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<RawPacket>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/receiver_report/mod.rs
Original file line number Diff line number Diff line change
@@ -80,10 +80,7 @@ impl Packet for ReceiverReport {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<ReceiverReport>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<ReceiverReport>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/reception_report.rs
Original file line number Diff line number Diff line change
@@ -73,10 +73,7 @@ impl Packet for ReceptionReport {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<ReceptionReport>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<ReceptionReport>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/sender_report/mod.rs
Original file line number Diff line number Diff line change
@@ -117,10 +117,7 @@ impl Packet for SenderReport {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<SenderReport>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<SenderReport>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/source_description/mod.rs
Original file line number Diff line number Diff line change
@@ -321,10 +321,7 @@ impl Packet for SourceDescription {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<SourceDescription>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<SourceDescription>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ impl Packet for RapidResynchronizationRequest {
other
.as_any()
.downcast_ref::<RapidResynchronizationRequest>()
.map_or(false, |a| self == a)
== Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/transport_feedbacks/transport_layer_cc/mod.rs
Original file line number Diff line number Diff line change
@@ -507,10 +507,7 @@ impl Packet for TransportLayerCc {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<TransportLayerCc>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<TransportLayerCc>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5 changes: 1 addition & 4 deletions rtcp/src/transport_feedbacks/transport_layer_nack/mod.rs
Original file line number Diff line number Diff line change
@@ -154,10 +154,7 @@ impl Packet for TransportLayerNack {
}

fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
other
.as_any()
.downcast_ref::<TransportLayerNack>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<TransportLayerNack>() == Some(self)
}

fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
1 change: 1 addition & 0 deletions srtp/src/session/mod.rs
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ const DEFAULT_SESSION_SRTCP_REPLAY_PROTECTION_WINDOW: usize = 64;
pub struct Session {
local_context: Arc<Mutex<Context>>,
streams_map: Arc<Mutex<HashMap<u32, Arc<Stream>>>>,
#[allow(clippy::type_complexity)]
new_stream_rx: Arc<Mutex<mpsc::Receiver<(Arc<Stream>, Option<rtp::header::Header>)>>>,
close_stream_tx: mpsc::Sender<u32>,
close_session_tx: mpsc::Sender<()>,
5 changes: 1 addition & 4 deletions webrtc/src/rtp_transceiver/fmtp/generic/mod.rs
Original file line number Diff line number Diff line change
@@ -53,10 +53,7 @@ impl Fmtp for GenericFmtp {
}

fn equal(&self, other: &(dyn Fmtp)) -> bool {
other
.as_any()
.downcast_ref::<GenericFmtp>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<GenericFmtp>() == Some(self)
}

fn as_any(&self) -> &(dyn Any) {
5 changes: 1 addition & 4 deletions webrtc/src/rtp_transceiver/fmtp/h264/mod.rs
Original file line number Diff line number Diff line change
@@ -90,10 +90,7 @@ impl Fmtp for H264Fmtp {
}

fn equal(&self, other: &(dyn Fmtp)) -> bool {
other
.as_any()
.downcast_ref::<H264Fmtp>()
.map_or(false, |a| self == a)
other.as_any().downcast_ref::<H264Fmtp>() == Some(self)
}

fn as_any(&self) -> &(dyn Any) {

0 comments on commit 761d70d

Please sign in to comment.