Skip to content

Commit ffead9f

Browse files
author
yngrtc
committed
fix clippy and fmt
1 parent 0aa7c07 commit ffead9f

File tree

31 files changed

+32
-88
lines changed

31 files changed

+32
-88
lines changed

Diff for: dtls/src/extension/extension_server_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl ExtensionServerName {
2121

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

2727
pub fn marshal<W: Write>(&self, writer: &mut W) -> Result<()> {

Diff for: ice/src/agent/agent_internal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ impl AgentInternal {
984984
) -> bool {
985985
self.find_remote_candidate(local.network_type(), remote)
986986
.await
987-
.map_or(false, |remote_candidate| {
987+
.is_some_and(|remote_candidate| {
988988
remote_candidate.seen(false);
989989
true
990990
})

Diff for: ice/src/agent/agent_test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1599,8 +1599,8 @@ async fn test_agent_credentials() -> Result<()> {
15991599
let a = Agent::new(AgentConfig::default()).await?;
16001600
{
16011601
let ufrag_pwd = a.internal.ufrag_pwd.lock().await;
1602-
assert!(ufrag_pwd.local_ufrag.as_bytes().len() * 8 >= 24);
1603-
assert!(ufrag_pwd.local_pwd.as_bytes().len() * 8 >= 128);
1602+
assert!(ufrag_pwd.local_ufrag.len() * 8 >= 24);
1603+
assert!(ufrag_pwd.local_pwd.len() * 8 >= 128);
16041604
}
16051605
a.close().await?;
16061606

Diff for: ice/src/agent/agent_vnet_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ async fn test_write_use_valid_pair() -> Result<(), Error> {
10021002
log::debug!("controlled_agent start_connectivity_checks done...");
10031003

10041004
let test_message = "Test Message";
1005-
let mut read_buf = vec![0u8; test_message.as_bytes().len()];
1005+
let mut read_buf = vec![0u8; test_message.len()];
10061006
controlled_agent_conn.recv(&mut read_buf).await?;
10071007

10081008
assert_eq!(read_buf, test_message.as_bytes(), "should match");

Diff for: mdns/src/message/resource/txt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl ResourceBody for TxtResource {
4343
let (t, new_off) = unpack_str(msg, off)?;
4444
off = new_off;
4545
// Check if we got too many bytes.
46-
if length < n + t.as_bytes().len() + 1 {
46+
if length < n + t.len() + 1 {
4747
return Err(Error::ErrCalcLen);
4848
}
4949
n += t.len() + 1;

Diff for: rtcp/src/compound_packet/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ impl Packet for CompoundPacket {
6666
}
6767

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

7572
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/extended_report/dlrr.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ impl Packet for DLRRReportBlock {
7777
self
7878
}
7979
fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
80-
other
81-
.as_any()
82-
.downcast_ref::<DLRRReportBlock>()
83-
.map_or(false, |a| self == a)
80+
other.as_any().downcast_ref::<DLRRReportBlock>() == Some(self)
8481
}
8582
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
8683
Box::new(self.clone())

Diff for: rtcp/src/extended_report/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ impl Packet for ExtendedReport {
199199
}
200200

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

208205
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/extended_report/prt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Packet for PacketReceiptTimesReportBlock {
7171
other
7272
.as_any()
7373
.downcast_ref::<PacketReceiptTimesReportBlock>()
74-
.map_or(false, |a| self == a)
74+
== Some(self)
7575
}
7676
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
7777
Box::new(self.clone())

Diff for: rtcp/src/extended_report/rle.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,7 @@ impl Packet for RLEReportBlock {
163163
self
164164
}
165165
fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
166-
other
167-
.as_any()
168-
.downcast_ref::<RLEReportBlock>()
169-
.map_or(false, |a| self == a)
166+
other.as_any().downcast_ref::<RLEReportBlock>() == Some(self)
170167
}
171168
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
172169
Box::new(self.clone())

Diff for: rtcp/src/extended_report/rrt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl Packet for ReceiverReferenceTimeReportBlock {
5656
other
5757
.as_any()
5858
.downcast_ref::<ReceiverReferenceTimeReportBlock>()
59-
.map_or(false, |a| self == a)
59+
== Some(self)
6060
}
6161
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
6262
Box::new(self.clone())

Diff for: rtcp/src/extended_report/ssr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl Packet for StatisticsSummaryReportBlock {
132132
other
133133
.as_any()
134134
.downcast_ref::<StatisticsSummaryReportBlock>()
135-
.map_or(false, |a| self == a)
135+
== Some(self)
136136
}
137137
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
138138
Box::new(self.clone())

Diff for: rtcp/src/extended_report/unknown.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ impl Packet for UnknownReportBlock {
4141
self
4242
}
4343
fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
44-
other
45-
.as_any()
46-
.downcast_ref::<UnknownReportBlock>()
47-
.map_or(false, |a| self == a)
44+
other.as_any().downcast_ref::<UnknownReportBlock>() == Some(self)
4845
}
4946
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
5047
Box::new(self.clone())

Diff for: rtcp/src/extended_report/vm.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ impl Packet for VoIPMetricsReportBlock {
8686
self
8787
}
8888
fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool {
89-
other
90-
.as_any()
91-
.downcast_ref::<VoIPMetricsReportBlock>()
92-
.map_or(false, |a| self == a)
89+
other.as_any().downcast_ref::<VoIPMetricsReportBlock>() == Some(self)
9390
}
9491
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {
9592
Box::new(self.clone())

Diff for: rtcp/src/goodbye/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ impl Packet for Goodbye {
6363
}
6464

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

7269
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/payload_feedbacks/full_intra_request/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ impl Packet for FullIntraRequest {
7171
}
7272

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

8077
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/payload_feedbacks/picture_loss_indication/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ impl Packet for PictureLossIndication {
6060
}
6161

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

6966
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/payload_feedbacks/receiver_estimated_maximum_bitrate/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Packet for ReceiverEstimatedMaximumBitrate {
9090
other
9191
.as_any()
9292
.downcast_ref::<ReceiverEstimatedMaximumBitrate>()
93-
.map_or(false, |a| self == a)
93+
== Some(self)
9494
}
9595

9696
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/payload_feedbacks/slice_loss_indication/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ impl Packet for SliceLossIndication {
7575
}
7676

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

8481
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/raw_packet.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ impl Packet for RawPacket {
4040
}
4141

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

4946
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/receiver_report/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ impl Packet for ReceiverReport {
8080
}
8181

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

8986
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/reception_report.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ impl Packet for ReceptionReport {
7373
}
7474

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

8279
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/sender_report/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,7 @@ impl Packet for SenderReport {
117117
}
118118

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

126123
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/source_description/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,7 @@ impl Packet for SourceDescription {
321321
}
322322

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

330327
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/transport_feedbacks/rapid_resynchronization_request/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Packet for RapidResynchronizationRequest {
6565
other
6666
.as_any()
6767
.downcast_ref::<RapidResynchronizationRequest>()
68-
.map_or(false, |a| self == a)
68+
== Some(self)
6969
}
7070

7171
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/transport_feedbacks/transport_layer_cc/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,7 @@ impl Packet for TransportLayerCc {
507507
}
508508

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

516513
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: rtcp/src/transport_feedbacks/transport_layer_nack/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ impl Packet for TransportLayerNack {
154154
}
155155

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

163160
fn cloned(&self) -> Box<dyn Packet + Send + Sync> {

Diff for: srtp/src/session/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const DEFAULT_SESSION_SRTCP_REPLAY_PROTECTION_WINDOW: usize = 64;
2828
pub struct Session {
2929
local_context: Arc<Mutex<Context>>,
3030
streams_map: Arc<Mutex<HashMap<u32, Arc<Stream>>>>,
31+
#[allow(clippy::type_complexity)]
3132
new_stream_rx: Arc<Mutex<mpsc::Receiver<(Arc<Stream>, Option<rtp::header::Header>)>>>,
3233
close_stream_tx: mpsc::Sender<u32>,
3334
close_session_tx: mpsc::Sender<()>,

Diff for: turn/examples/turn_client_udp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ async fn do_ping_test(
185185
// Send 10 packets from relay_conn to the echo server
186186
for _ in 0..2 {
187187
let msg = "12345678910".to_owned(); //format!("{:?}", tokio::time::Instant::now());
188-
println!("sending msg={} with size={}", msg, msg.as_bytes().len());
188+
println!("sending msg={} with size={}", msg, msg.len());
189189
pinger_conn_tx.send_to(msg.as_bytes(), relay_addr).await?;
190190

191191
// For simplicity, this example does not wait for the pong (reply).

Diff for: webrtc/src/rtp_transceiver/fmtp/generic/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ impl Fmtp for GenericFmtp {
5353
}
5454

5555
fn equal(&self, other: &(dyn Fmtp)) -> bool {
56-
other
57-
.as_any()
58-
.downcast_ref::<GenericFmtp>()
59-
.map_or(false, |a| self == a)
56+
other.as_any().downcast_ref::<GenericFmtp>() == Some(self)
6057
}
6158

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

Diff for: webrtc/src/rtp_transceiver/fmtp/h264/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ impl Fmtp for H264Fmtp {
9090
}
9191

9292
fn equal(&self, other: &(dyn Fmtp)) -> bool {
93-
other
94-
.as_any()
95-
.downcast_ref::<H264Fmtp>()
96-
.map_or(false, |a| self == a)
93+
other.as_any().downcast_ref::<H264Fmtp>() == Some(self)
9794
}
9895

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

0 commit comments

Comments
 (0)