Skip to content

Commit 5402eaf

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

File tree

31 files changed

+68
-125
lines changed

31 files changed

+68
-125
lines changed

dtls/src/extension/extension_server_name.rs

Lines changed: 1 addition & 1 deletion
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<()> {

ice/src/agent/agent_internal.rs

Lines changed: 1 addition & 1 deletion
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
})

ice/src/agent/agent_test.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async fn test_pair_priority() -> Result<()> {
152152
local: host_local.clone(),
153153
..Default::default()
154154
}
155-
.to_string(),
155+
.to_string(),
156156
"Unexpected bestPair {best_pair} (expected remote: {remote})",
157157
);
158158
} else {
@@ -662,7 +662,7 @@ async fn test_inbound_validity() -> Result<()> {
662662
},
663663
..Default::default()
664664
}
665-
.new_candidate_host()?,
665+
.new_candidate_host()?,
666666
);
667667

668668
//"Invalid Binding requests should be discarded"
@@ -1064,7 +1064,7 @@ async fn test_candidate_pair_stats() -> Result<()> {
10641064
},
10651065
..Default::default()
10661066
}
1067-
.new_candidate_host()?,
1067+
.new_candidate_host()?,
10681068
);
10691069

10701070
let relay_remote: Arc<dyn Candidate + Send + Sync> = Arc::new(
@@ -1080,7 +1080,7 @@ async fn test_candidate_pair_stats() -> Result<()> {
10801080
rel_port: 43210,
10811081
..Default::default()
10821082
}
1083-
.new_candidate_relay()?,
1083+
.new_candidate_relay()?,
10841084
);
10851085

10861086
let srflx_remote: Arc<dyn Candidate + Send + Sync> = Arc::new(
@@ -1095,7 +1095,7 @@ async fn test_candidate_pair_stats() -> Result<()> {
10951095
rel_addr: "4.3.2.1".to_owned(),
10961096
rel_port: 43212,
10971097
}
1098-
.new_candidate_server_reflexive()?,
1098+
.new_candidate_server_reflexive()?,
10991099
);
11001100

11011101
let prflx_remote: Arc<dyn Candidate + Send + Sync> = Arc::new(
@@ -1110,7 +1110,7 @@ async fn test_candidate_pair_stats() -> Result<()> {
11101110
rel_addr: "4.3.2.1".to_owned(),
11111111
rel_port: 43211,
11121112
}
1113-
.new_candidate_peer_reflexive()?,
1113+
.new_candidate_peer_reflexive()?,
11141114
);
11151115

11161116
let host_remote: Arc<dyn Candidate + Send + Sync> = Arc::new(
@@ -1124,7 +1124,7 @@ async fn test_candidate_pair_stats() -> Result<()> {
11241124
},
11251125
..Default::default()
11261126
}
1127-
.new_candidate_host()?,
1127+
.new_candidate_host()?,
11281128
);
11291129

11301130
for remote in &[
@@ -1226,7 +1226,7 @@ async fn test_local_candidate_stats() -> Result<()> {
12261226
},
12271227
..Default::default()
12281228
}
1229-
.new_candidate_host()?,
1229+
.new_candidate_host()?,
12301230
);
12311231

12321232
let srflx_local: Arc<dyn Candidate + Send + Sync> = Arc::new(
@@ -1241,7 +1241,7 @@ async fn test_local_candidate_stats() -> Result<()> {
12411241
rel_addr: "4.3.2.1".to_owned(),
12421242
rel_port: 43212,
12431243
}
1244-
.new_candidate_server_reflexive()?,
1244+
.new_candidate_server_reflexive()?,
12451245
);
12461246

12471247
{
@@ -1319,7 +1319,7 @@ async fn test_remote_candidate_stats() -> Result<()> {
13191319
rel_port: 43210,
13201320
..Default::default()
13211321
}
1322-
.new_candidate_relay()?,
1322+
.new_candidate_relay()?,
13231323
);
13241324

13251325
let srflx_remote: Arc<dyn Candidate + Send + Sync> = Arc::new(
@@ -1334,7 +1334,7 @@ async fn test_remote_candidate_stats() -> Result<()> {
13341334
rel_addr: "4.3.2.1".to_owned(),
13351335
rel_port: 43212,
13361336
}
1337-
.new_candidate_server_reflexive()?,
1337+
.new_candidate_server_reflexive()?,
13381338
);
13391339

13401340
let prflx_remote: Arc<dyn Candidate + Send + Sync> = Arc::new(
@@ -1349,7 +1349,7 @@ async fn test_remote_candidate_stats() -> Result<()> {
13491349
rel_addr: "4.3.2.1".to_owned(),
13501350
rel_port: 43211,
13511351
}
1352-
.new_candidate_peer_reflexive()?,
1352+
.new_candidate_peer_reflexive()?,
13531353
);
13541354

13551355
let host_remote: Arc<dyn Candidate + Send + Sync> = Arc::new(
@@ -1363,7 +1363,7 @@ async fn test_remote_candidate_stats() -> Result<()> {
13631363
},
13641364
..Default::default()
13651365
}
1366-
.new_candidate_host()?,
1366+
.new_candidate_host()?,
13671367
);
13681368

13691369
{
@@ -1465,7 +1465,7 @@ async fn test_init_ext_ip_mapping() -> Result<()> {
14651465
nat_1to1_ip_candidate_type: CandidateType::Host,
14661466
..Default::default()
14671467
})
1468-
.await?;
1468+
.await?;
14691469
assert!(
14701470
a.ext_ip_mapper.is_none(),
14711471
"a.extIPMapper should be none by default"
@@ -1480,7 +1480,7 @@ async fn test_init_ext_ip_mapping() -> Result<()> {
14801480
candidate_types: vec![CandidateType::Relay],
14811481
..Default::default()
14821482
})
1483-
.await
1483+
.await
14841484
{
14851485
assert_eq!(
14861486
Error::ErrIneffectiveNat1to1IpMappingHost,
@@ -1499,7 +1499,7 @@ async fn test_init_ext_ip_mapping() -> Result<()> {
14991499
candidate_types: vec![CandidateType::Relay],
15001500
..Default::default()
15011501
})
1502-
.await
1502+
.await
15031503
{
15041504
assert_eq!(
15051505
Error::ErrIneffectiveNat1to1IpMappingSrflx,
@@ -1518,7 +1518,7 @@ async fn test_init_ext_ip_mapping() -> Result<()> {
15181518
multicast_dns_mode: MulticastDnsMode::QueryAndGather,
15191519
..Default::default()
15201520
})
1521-
.await
1521+
.await
15221522
{
15231523
assert_eq!(
15241524
Error::ErrMulticastDnsWithNat1to1IpMapping,
@@ -1535,7 +1535,7 @@ async fn test_init_ext_ip_mapping() -> Result<()> {
15351535
nat_1to1_ip_candidate_type: CandidateType::Host,
15361536
..Default::default()
15371537
})
1538-
.await
1538+
.await
15391539
{
15401540
assert_eq!(
15411541
Error::ErrInvalidNat1to1IpMapping,
@@ -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

@@ -1613,7 +1613,7 @@ async fn test_agent_credentials() -> Result<()> {
16131613
local_ufrag: "xx".to_owned(),
16141614
..Default::default()
16151615
})
1616-
.await
1616+
.await
16171617
{
16181618
assert_eq!(Error::ErrLocalUfragInsufficientBits, err);
16191619
} else {
@@ -1624,7 +1624,7 @@ async fn test_agent_credentials() -> Result<()> {
16241624
local_pwd: "xxxxxx".to_owned(),
16251625
..Default::default()
16261626
})
1627-
.await
1627+
.await
16281628
{
16291629
assert_eq!(Error::ErrLocalPwdInsufficientBits, err);
16301630
} else {
@@ -1824,7 +1824,7 @@ async fn test_agent_restart_one_side() -> Result<()> {
18241824
..Default::default()
18251825
}),
18261826
)
1827-
.await?;
1827+
.await?;
18281828

18291829
let (cancel_tx, mut cancel_rx) = mpsc::channel::<()>(1);
18301830
let cancel_tx = Arc::new(Mutex::new(Some(cancel_tx)));
@@ -1882,7 +1882,7 @@ async fn test_agent_restart_both_side() -> Result<()> {
18821882
..Default::default()
18831883
}),
18841884
)
1885-
.await?;
1885+
.await?;
18861886

18871887
let conn_afirst_candidates =
18881888
generate_candidate_address_strings(agent_a.get_local_candidates().await);
@@ -2138,7 +2138,7 @@ async fn test_lite_lifecycle() -> Result<()> {
21382138
multicast_dns_mode: MulticastDnsMode::Disabled,
21392139
..Default::default()
21402140
})
2141-
.await?,
2141+
.await?,
21422142
);
21432143

21442144
a_agent.on_connection_state_change(a_notifier);
@@ -2159,7 +2159,7 @@ async fn test_lite_lifecycle() -> Result<()> {
21592159
check_interval: Duration::from_millis(500),
21602160
..Default::default()
21612161
})
2162-
.await?,
2162+
.await?,
21632163
);
21642164

21652165
let (b_connected_tx, mut b_connected_rx) = mpsc::channel::<()>(1);

ice/src/agent/agent_vnet_test.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub(crate) async fn add_vnet_stun(wan_net: Arc<net::Net>) -> Result<turn::server
245245
channel_bind_timeout: Duration::from_secs(0),
246246
alloc_close_notify: None,
247247
})
248-
.await?;
248+
.await?;
249249

250250
Ok(server)
251251
}
@@ -683,8 +683,7 @@ async fn test_connectivity_vnet_1to1_nat_with_host_candidate_vs_symmetric_nats()
683683
}
684684

685685
#[tokio::test]
686-
async fn test_connectivity_vnet_1to1_nat_with_srflx_candidate_vs_symmetric_nats(
687-
) -> Result<(), Error> {
686+
async fn test_connectivity_vnet_1to1_nat_with_srflx_candidate_vs_symmetric_nats() -> Result<(), Error> {
688687
/*env_logger::Builder::new()
689688
.format(|buf, record| {
690689
writeln!(
@@ -775,7 +774,7 @@ async fn test_disconnected_to_connected() -> Result<(), Error> {
775774
wan.add_chunk_filter(Box::new(move |_c: &(dyn Chunk + Send + Sync)| -> bool {
776775
drop_all_data2.load(Ordering::SeqCst) != 1
777776
}))
778-
.await;
777+
.await;
779778
let wan = Arc::new(Mutex::new(wan));
780779

781780
let net0 = Arc::new(net::Net::new(Some(net::NetConfig {
@@ -805,7 +804,7 @@ async fn test_disconnected_to_connected() -> Result<(), Error> {
805804
check_interval: keepalive_interval,
806805
..Default::default()
807806
})
808-
.await?,
807+
.await?,
809808
);
810809

811810
let controlled_agent = Arc::new(
@@ -818,7 +817,7 @@ async fn test_disconnected_to_connected() -> Result<(), Error> {
818817
check_interval: keepalive_interval,
819818
..Default::default()
820819
})
821-
.await?,
820+
.await?,
822821
);
823822

824823
let (controlling_state_changes_tx, mut controlling_state_changes_rx) =
@@ -848,7 +847,7 @@ async fn test_disconnected_to_connected() -> Result<(), Error> {
848847
ConnectionState::Connected,
849848
&mut controlling_state_changes_rx,
850849
)
851-
.await;
850+
.await;
852851
block_until_state_seen(ConnectionState::Connected, &mut controlled_state_changes_rx).await;
853852

854853
// Drop all packets, and block until we have gone to disconnected
@@ -857,20 +856,20 @@ async fn test_disconnected_to_connected() -> Result<(), Error> {
857856
ConnectionState::Disconnected,
858857
&mut controlling_state_changes_rx,
859858
)
860-
.await;
859+
.await;
861860
block_until_state_seen(
862861
ConnectionState::Disconnected,
863862
&mut controlled_state_changes_rx,
864863
)
865-
.await;
864+
.await;
866865

867866
// Allow all packets through again, block until we have gone to connected
868867
drop_all_data.store(0, Ordering::SeqCst);
869868
block_until_state_seen(
870869
ConnectionState::Connected,
871870
&mut controlling_state_changes_rx,
872871
)
873-
.await;
872+
.await;
874873
block_until_state_seen(ConnectionState::Connected, &mut controlled_state_changes_rx).await;
875874

876875
{
@@ -925,7 +924,7 @@ async fn test_write_use_valid_pair() -> Result<(), Error> {
925924

926925
true
927926
}))
928-
.await;
927+
.await;
929928
let wan = Arc::new(Mutex::new(wan));
930929

931930
let net0 = Arc::new(net::Net::new(Some(net::NetConfig {
@@ -949,7 +948,7 @@ async fn test_write_use_valid_pair() -> Result<(), Error> {
949948
net: Some(Arc::clone(&net0)),
950949
..Default::default()
951950
})
952-
.await?,
951+
.await?,
953952
);
954953

955954
let controlled_agent = Arc::new(
@@ -959,7 +958,7 @@ async fn test_write_use_valid_pair() -> Result<(), Error> {
959958
net: Some(Arc::clone(&net1)),
960959
..Default::default()
961960
})
962-
.await?,
961+
.await?,
963962
);
964963

965964
gather_and_exchange_candidates(&controlling_agent, &controlled_agent).await?;
@@ -1002,7 +1001,7 @@ async fn test_write_use_valid_pair() -> Result<(), Error> {
10021001
log::debug!("controlled_agent start_connectivity_checks done...");
10031002

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

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

mdns/src/message/resource/txt.rs

Lines changed: 1 addition & 1 deletion
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;

rtcp/src/compound_packet/mod.rs

Lines changed: 1 addition & 4 deletions
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> {

rtcp/src/extended_report/dlrr.rs

Lines changed: 1 addition & 4 deletions
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())

0 commit comments

Comments
 (0)