From 5402eaf91facc445234a3f17bef9a2a6dd0c41c9 Mon Sep 17 00:00:00 2001 From: yngrtc Date: Sun, 26 Jan 2025 12:06:45 -0800 Subject: [PATCH] fix clippy and fmt --- dtls/src/extension/extension_server_name.rs | 2 +- ice/src/agent/agent_internal.rs | 2 +- ice/src/agent/agent_test.rs | 52 +++++++++---------- ice/src/agent/agent_vnet_test.rs | 27 +++++----- mdns/src/message/resource/txt.rs | 2 +- rtcp/src/compound_packet/mod.rs | 5 +- rtcp/src/extended_report/dlrr.rs | 5 +- rtcp/src/extended_report/mod.rs | 5 +- rtcp/src/extended_report/prt.rs | 2 +- rtcp/src/extended_report/rle.rs | 5 +- rtcp/src/extended_report/rrt.rs | 2 +- rtcp/src/extended_report/ssr.rs | 2 +- rtcp/src/extended_report/unknown.rs | 5 +- rtcp/src/extended_report/vm.rs | 5 +- rtcp/src/goodbye/mod.rs | 5 +- .../full_intra_request/mod.rs | 5 +- .../picture_loss_indication/mod.rs | 5 +- .../receiver_estimated_maximum_bitrate/mod.rs | 2 +- .../slice_loss_indication/mod.rs | 5 +- rtcp/src/raw_packet.rs | 5 +- rtcp/src/receiver_report/mod.rs | 5 +- rtcp/src/reception_report.rs | 5 +- rtcp/src/sender_report/mod.rs | 5 +- rtcp/src/source_description/mod.rs | 5 +- .../rapid_resynchronization_request/mod.rs | 2 +- .../transport_layer_cc/mod.rs | 5 +- .../transport_layer_nack/mod.rs | 5 +- srtp/src/session/mod.rs | 1 + turn/examples/turn_client_udp.rs | 2 +- .../src/rtp_transceiver/fmtp/generic/mod.rs | 5 +- webrtc/src/rtp_transceiver/fmtp/h264/mod.rs | 5 +- 31 files changed, 68 insertions(+), 125 deletions(-) diff --git a/dtls/src/extension/extension_server_name.rs b/dtls/src/extension/extension_server_name.rs index dbe018e9f..92fd259b2 100644 --- a/dtls/src/extension/extension_server_name.rs +++ b/dtls/src/extension/extension_server_name.rs @@ -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(&self, writer: &mut W) -> Result<()> { diff --git a/ice/src/agent/agent_internal.rs b/ice/src/agent/agent_internal.rs index dc943b5b4..6532f7f79 100644 --- a/ice/src/agent/agent_internal.rs +++ b/ice/src/agent/agent_internal.rs @@ -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 }) diff --git a/ice/src/agent/agent_test.rs b/ice/src/agent/agent_test.rs index 0af395a6f..4c23fea38 100644 --- a/ice/src/agent/agent_test.rs +++ b/ice/src/agent/agent_test.rs @@ -152,7 +152,7 @@ async fn test_pair_priority() -> Result<()> { local: host_local.clone(), ..Default::default() } - .to_string(), + .to_string(), "Unexpected bestPair {best_pair} (expected remote: {remote})", ); } else { @@ -662,7 +662,7 @@ async fn test_inbound_validity() -> Result<()> { }, ..Default::default() } - .new_candidate_host()?, + .new_candidate_host()?, ); //"Invalid Binding requests should be discarded" @@ -1064,7 +1064,7 @@ async fn test_candidate_pair_stats() -> Result<()> { }, ..Default::default() } - .new_candidate_host()?, + .new_candidate_host()?, ); let relay_remote: Arc = Arc::new( @@ -1080,7 +1080,7 @@ async fn test_candidate_pair_stats() -> Result<()> { rel_port: 43210, ..Default::default() } - .new_candidate_relay()?, + .new_candidate_relay()?, ); let srflx_remote: Arc = Arc::new( @@ -1095,7 +1095,7 @@ async fn test_candidate_pair_stats() -> Result<()> { rel_addr: "4.3.2.1".to_owned(), rel_port: 43212, } - .new_candidate_server_reflexive()?, + .new_candidate_server_reflexive()?, ); let prflx_remote: Arc = Arc::new( @@ -1110,7 +1110,7 @@ async fn test_candidate_pair_stats() -> Result<()> { rel_addr: "4.3.2.1".to_owned(), rel_port: 43211, } - .new_candidate_peer_reflexive()?, + .new_candidate_peer_reflexive()?, ); let host_remote: Arc = Arc::new( @@ -1124,7 +1124,7 @@ async fn test_candidate_pair_stats() -> Result<()> { }, ..Default::default() } - .new_candidate_host()?, + .new_candidate_host()?, ); for remote in &[ @@ -1226,7 +1226,7 @@ async fn test_local_candidate_stats() -> Result<()> { }, ..Default::default() } - .new_candidate_host()?, + .new_candidate_host()?, ); let srflx_local: Arc = Arc::new( @@ -1241,7 +1241,7 @@ async fn test_local_candidate_stats() -> Result<()> { rel_addr: "4.3.2.1".to_owned(), rel_port: 43212, } - .new_candidate_server_reflexive()?, + .new_candidate_server_reflexive()?, ); { @@ -1319,7 +1319,7 @@ async fn test_remote_candidate_stats() -> Result<()> { rel_port: 43210, ..Default::default() } - .new_candidate_relay()?, + .new_candidate_relay()?, ); let srflx_remote: Arc = Arc::new( @@ -1334,7 +1334,7 @@ async fn test_remote_candidate_stats() -> Result<()> { rel_addr: "4.3.2.1".to_owned(), rel_port: 43212, } - .new_candidate_server_reflexive()?, + .new_candidate_server_reflexive()?, ); let prflx_remote: Arc = Arc::new( @@ -1349,7 +1349,7 @@ async fn test_remote_candidate_stats() -> Result<()> { rel_addr: "4.3.2.1".to_owned(), rel_port: 43211, } - .new_candidate_peer_reflexive()?, + .new_candidate_peer_reflexive()?, ); let host_remote: Arc = Arc::new( @@ -1363,7 +1363,7 @@ async fn test_remote_candidate_stats() -> Result<()> { }, ..Default::default() } - .new_candidate_host()?, + .new_candidate_host()?, ); { @@ -1465,7 +1465,7 @@ async fn test_init_ext_ip_mapping() -> Result<()> { nat_1to1_ip_candidate_type: CandidateType::Host, ..Default::default() }) - .await?; + .await?; assert!( a.ext_ip_mapper.is_none(), "a.extIPMapper should be none by default" @@ -1480,7 +1480,7 @@ async fn test_init_ext_ip_mapping() -> Result<()> { candidate_types: vec![CandidateType::Relay], ..Default::default() }) - .await + .await { assert_eq!( Error::ErrIneffectiveNat1to1IpMappingHost, @@ -1499,7 +1499,7 @@ async fn test_init_ext_ip_mapping() -> Result<()> { candidate_types: vec![CandidateType::Relay], ..Default::default() }) - .await + .await { assert_eq!( Error::ErrIneffectiveNat1to1IpMappingSrflx, @@ -1518,7 +1518,7 @@ async fn test_init_ext_ip_mapping() -> Result<()> { multicast_dns_mode: MulticastDnsMode::QueryAndGather, ..Default::default() }) - .await + .await { assert_eq!( Error::ErrMulticastDnsWithNat1to1IpMapping, @@ -1535,7 +1535,7 @@ async fn test_init_ext_ip_mapping() -> Result<()> { nat_1to1_ip_candidate_type: CandidateType::Host, ..Default::default() }) - .await + .await { assert_eq!( Error::ErrInvalidNat1to1IpMapping, @@ -1599,8 +1599,8 @@ async fn test_agent_credentials() -> Result<()> { let a = Agent::new(AgentConfig::default()).await?; { let ufrag_pwd = a.internal.ufrag_pwd.lock().await; - assert!(ufrag_pwd.local_ufrag.as_bytes().len() * 8 >= 24); - assert!(ufrag_pwd.local_pwd.as_bytes().len() * 8 >= 128); + assert!(ufrag_pwd.local_ufrag.len() * 8 >= 24); + assert!(ufrag_pwd.local_pwd.len() * 8 >= 128); } a.close().await?; @@ -1613,7 +1613,7 @@ async fn test_agent_credentials() -> Result<()> { local_ufrag: "xx".to_owned(), ..Default::default() }) - .await + .await { assert_eq!(Error::ErrLocalUfragInsufficientBits, err); } else { @@ -1624,7 +1624,7 @@ async fn test_agent_credentials() -> Result<()> { local_pwd: "xxxxxx".to_owned(), ..Default::default() }) - .await + .await { assert_eq!(Error::ErrLocalPwdInsufficientBits, err); } else { @@ -1824,7 +1824,7 @@ async fn test_agent_restart_one_side() -> Result<()> { ..Default::default() }), ) - .await?; + .await?; let (cancel_tx, mut cancel_rx) = mpsc::channel::<()>(1); let cancel_tx = Arc::new(Mutex::new(Some(cancel_tx))); @@ -1882,7 +1882,7 @@ async fn test_agent_restart_both_side() -> Result<()> { ..Default::default() }), ) - .await?; + .await?; let conn_afirst_candidates = generate_candidate_address_strings(agent_a.get_local_candidates().await); @@ -2138,7 +2138,7 @@ async fn test_lite_lifecycle() -> Result<()> { multicast_dns_mode: MulticastDnsMode::Disabled, ..Default::default() }) - .await?, + .await?, ); a_agent.on_connection_state_change(a_notifier); @@ -2159,7 +2159,7 @@ async fn test_lite_lifecycle() -> Result<()> { check_interval: Duration::from_millis(500), ..Default::default() }) - .await?, + .await?, ); let (b_connected_tx, mut b_connected_rx) = mpsc::channel::<()>(1); diff --git a/ice/src/agent/agent_vnet_test.rs b/ice/src/agent/agent_vnet_test.rs index 5974a63e0..58e70dded 100644 --- a/ice/src/agent/agent_vnet_test.rs +++ b/ice/src/agent/agent_vnet_test.rs @@ -245,7 +245,7 @@ pub(crate) async fn add_vnet_stun(wan_net: Arc) -> Result Result<(), Error> { +async fn test_connectivity_vnet_1to1_nat_with_srflx_candidate_vs_symmetric_nats() -> Result<(), Error> { /*env_logger::Builder::new() .format(|buf, record| { writeln!( @@ -775,7 +774,7 @@ async fn test_disconnected_to_connected() -> Result<(), Error> { wan.add_chunk_filter(Box::new(move |_c: &(dyn Chunk + Send + Sync)| -> bool { drop_all_data2.load(Ordering::SeqCst) != 1 })) - .await; + .await; let wan = Arc::new(Mutex::new(wan)); let net0 = Arc::new(net::Net::new(Some(net::NetConfig { @@ -805,7 +804,7 @@ async fn test_disconnected_to_connected() -> Result<(), Error> { check_interval: keepalive_interval, ..Default::default() }) - .await?, + .await?, ); let controlled_agent = Arc::new( @@ -818,7 +817,7 @@ async fn test_disconnected_to_connected() -> Result<(), Error> { check_interval: keepalive_interval, ..Default::default() }) - .await?, + .await?, ); let (controlling_state_changes_tx, mut controlling_state_changes_rx) = @@ -848,7 +847,7 @@ async fn test_disconnected_to_connected() -> Result<(), Error> { ConnectionState::Connected, &mut controlling_state_changes_rx, ) - .await; + .await; block_until_state_seen(ConnectionState::Connected, &mut controlled_state_changes_rx).await; // Drop all packets, and block until we have gone to disconnected @@ -857,12 +856,12 @@ async fn test_disconnected_to_connected() -> Result<(), Error> { ConnectionState::Disconnected, &mut controlling_state_changes_rx, ) - .await; + .await; block_until_state_seen( ConnectionState::Disconnected, &mut controlled_state_changes_rx, ) - .await; + .await; // Allow all packets through again, block until we have gone to connected drop_all_data.store(0, Ordering::SeqCst); @@ -870,7 +869,7 @@ async fn test_disconnected_to_connected() -> Result<(), Error> { ConnectionState::Connected, &mut controlling_state_changes_rx, ) - .await; + .await; block_until_state_seen(ConnectionState::Connected, &mut controlled_state_changes_rx).await; { @@ -925,7 +924,7 @@ async fn test_write_use_valid_pair() -> Result<(), Error> { true })) - .await; + .await; let wan = Arc::new(Mutex::new(wan)); let net0 = Arc::new(net::Net::new(Some(net::NetConfig { @@ -949,7 +948,7 @@ async fn test_write_use_valid_pair() -> Result<(), Error> { net: Some(Arc::clone(&net0)), ..Default::default() }) - .await?, + .await?, ); let controlled_agent = Arc::new( @@ -959,7 +958,7 @@ async fn test_write_use_valid_pair() -> Result<(), Error> { net: Some(Arc::clone(&net1)), ..Default::default() }) - .await?, + .await?, ); gather_and_exchange_candidates(&controlling_agent, &controlled_agent).await?; @@ -1002,7 +1001,7 @@ async fn test_write_use_valid_pair() -> Result<(), Error> { log::debug!("controlled_agent start_connectivity_checks done..."); let test_message = "Test Message"; - let mut read_buf = vec![0u8; test_message.as_bytes().len()]; + let mut read_buf = vec![0u8; test_message.len()]; controlled_agent_conn.recv(&mut read_buf).await?; assert_eq!(read_buf, test_message.as_bytes(), "should match"); diff --git a/mdns/src/message/resource/txt.rs b/mdns/src/message/resource/txt.rs index 64888ff84..5b43c02bf 100644 --- a/mdns/src/message/resource/txt.rs +++ b/mdns/src/message/resource/txt.rs @@ -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; diff --git a/rtcp/src/compound_packet/mod.rs b/rtcp/src/compound_packet/mod.rs index 6a744f177..74b699574 100644 --- a/rtcp/src/compound_packet/mod.rs +++ b/rtcp/src/compound_packet/mod.rs @@ -66,10 +66,7 @@ impl Packet for CompoundPacket { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/extended_report/dlrr.rs b/rtcp/src/extended_report/dlrr.rs index c5d9693d3..0d24f5d12 100644 --- a/rtcp/src/extended_report/dlrr.rs +++ b/rtcp/src/extended_report/dlrr.rs @@ -77,10 +77,7 @@ impl Packet for DLRRReportBlock { self } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { Box::new(self.clone()) diff --git a/rtcp/src/extended_report/mod.rs b/rtcp/src/extended_report/mod.rs index e8a2f3732..ed9e49f1b 100644 --- a/rtcp/src/extended_report/mod.rs +++ b/rtcp/src/extended_report/mod.rs @@ -199,10 +199,7 @@ impl Packet for ExtendedReport { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/extended_report/prt.rs b/rtcp/src/extended_report/prt.rs index c9da820cb..9c3383b9b 100644 --- a/rtcp/src/extended_report/prt.rs +++ b/rtcp/src/extended_report/prt.rs @@ -71,7 +71,7 @@ impl Packet for PacketReceiptTimesReportBlock { other .as_any() .downcast_ref::() - .map_or(false, |a| self == a) + == Some(self) } fn cloned(&self) -> Box { Box::new(self.clone()) diff --git a/rtcp/src/extended_report/rle.rs b/rtcp/src/extended_report/rle.rs index fe6770b76..6677bb7c0 100644 --- a/rtcp/src/extended_report/rle.rs +++ b/rtcp/src/extended_report/rle.rs @@ -163,10 +163,7 @@ impl Packet for RLEReportBlock { self } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { Box::new(self.clone()) diff --git a/rtcp/src/extended_report/rrt.rs b/rtcp/src/extended_report/rrt.rs index fa0b34d65..8c069f595 100644 --- a/rtcp/src/extended_report/rrt.rs +++ b/rtcp/src/extended_report/rrt.rs @@ -56,7 +56,7 @@ impl Packet for ReceiverReferenceTimeReportBlock { other .as_any() .downcast_ref::() - .map_or(false, |a| self == a) + == Some(self) } fn cloned(&self) -> Box { Box::new(self.clone()) diff --git a/rtcp/src/extended_report/ssr.rs b/rtcp/src/extended_report/ssr.rs index c4c29e0b5..c1ee62bf5 100644 --- a/rtcp/src/extended_report/ssr.rs +++ b/rtcp/src/extended_report/ssr.rs @@ -132,7 +132,7 @@ impl Packet for StatisticsSummaryReportBlock { other .as_any() .downcast_ref::() - .map_or(false, |a| self == a) + == Some(self) } fn cloned(&self) -> Box { Box::new(self.clone()) diff --git a/rtcp/src/extended_report/unknown.rs b/rtcp/src/extended_report/unknown.rs index 707d77231..7243b1e4b 100644 --- a/rtcp/src/extended_report/unknown.rs +++ b/rtcp/src/extended_report/unknown.rs @@ -41,10 +41,7 @@ impl Packet for UnknownReportBlock { self } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { Box::new(self.clone()) diff --git a/rtcp/src/extended_report/vm.rs b/rtcp/src/extended_report/vm.rs index 91cb79099..834fea223 100644 --- a/rtcp/src/extended_report/vm.rs +++ b/rtcp/src/extended_report/vm.rs @@ -86,10 +86,7 @@ impl Packet for VoIPMetricsReportBlock { self } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { Box::new(self.clone()) diff --git a/rtcp/src/goodbye/mod.rs b/rtcp/src/goodbye/mod.rs index 9fa44fd77..a26dc949b 100644 --- a/rtcp/src/goodbye/mod.rs +++ b/rtcp/src/goodbye/mod.rs @@ -63,10 +63,7 @@ impl Packet for Goodbye { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/payload_feedbacks/full_intra_request/mod.rs b/rtcp/src/payload_feedbacks/full_intra_request/mod.rs index fa8440889..c2a9532c3 100644 --- a/rtcp/src/payload_feedbacks/full_intra_request/mod.rs +++ b/rtcp/src/payload_feedbacks/full_intra_request/mod.rs @@ -71,10 +71,7 @@ impl Packet for FullIntraRequest { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/payload_feedbacks/picture_loss_indication/mod.rs b/rtcp/src/payload_feedbacks/picture_loss_indication/mod.rs index 1092e0afc..1385afd7b 100644 --- a/rtcp/src/payload_feedbacks/picture_loss_indication/mod.rs +++ b/rtcp/src/payload_feedbacks/picture_loss_indication/mod.rs @@ -60,10 +60,7 @@ impl Packet for PictureLossIndication { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/payload_feedbacks/receiver_estimated_maximum_bitrate/mod.rs b/rtcp/src/payload_feedbacks/receiver_estimated_maximum_bitrate/mod.rs index df48a6886..592c70b34 100644 --- a/rtcp/src/payload_feedbacks/receiver_estimated_maximum_bitrate/mod.rs +++ b/rtcp/src/payload_feedbacks/receiver_estimated_maximum_bitrate/mod.rs @@ -90,7 +90,7 @@ impl Packet for ReceiverEstimatedMaximumBitrate { other .as_any() .downcast_ref::() - .map_or(false, |a| self == a) + == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/payload_feedbacks/slice_loss_indication/mod.rs b/rtcp/src/payload_feedbacks/slice_loss_indication/mod.rs index c424f5c60..9fba151fa 100644 --- a/rtcp/src/payload_feedbacks/slice_loss_indication/mod.rs +++ b/rtcp/src/payload_feedbacks/slice_loss_indication/mod.rs @@ -75,10 +75,7 @@ impl Packet for SliceLossIndication { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/raw_packet.rs b/rtcp/src/raw_packet.rs index dc5fc78d5..97a69cac1 100644 --- a/rtcp/src/raw_packet.rs +++ b/rtcp/src/raw_packet.rs @@ -40,10 +40,7 @@ impl Packet for RawPacket { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/receiver_report/mod.rs b/rtcp/src/receiver_report/mod.rs index 369c5d2c1..2ce8e49eb 100644 --- a/rtcp/src/receiver_report/mod.rs +++ b/rtcp/src/receiver_report/mod.rs @@ -80,10 +80,7 @@ impl Packet for ReceiverReport { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/reception_report.rs b/rtcp/src/reception_report.rs index b9c49f2ad..fb8bffb99 100644 --- a/rtcp/src/reception_report.rs +++ b/rtcp/src/reception_report.rs @@ -73,10 +73,7 @@ impl Packet for ReceptionReport { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/sender_report/mod.rs b/rtcp/src/sender_report/mod.rs index 1e66d9b83..0792ca3a3 100644 --- a/rtcp/src/sender_report/mod.rs +++ b/rtcp/src/sender_report/mod.rs @@ -117,10 +117,7 @@ impl Packet for SenderReport { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/source_description/mod.rs b/rtcp/src/source_description/mod.rs index 5cf66545b..ce3f19ba6 100644 --- a/rtcp/src/source_description/mod.rs +++ b/rtcp/src/source_description/mod.rs @@ -321,10 +321,7 @@ impl Packet for SourceDescription { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/transport_feedbacks/rapid_resynchronization_request/mod.rs b/rtcp/src/transport_feedbacks/rapid_resynchronization_request/mod.rs index 7ea106755..6709f9f4c 100644 --- a/rtcp/src/transport_feedbacks/rapid_resynchronization_request/mod.rs +++ b/rtcp/src/transport_feedbacks/rapid_resynchronization_request/mod.rs @@ -65,7 +65,7 @@ impl Packet for RapidResynchronizationRequest { other .as_any() .downcast_ref::() - .map_or(false, |a| self == a) + == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/transport_feedbacks/transport_layer_cc/mod.rs b/rtcp/src/transport_feedbacks/transport_layer_cc/mod.rs index 1637cc4e2..14014bf9d 100644 --- a/rtcp/src/transport_feedbacks/transport_layer_cc/mod.rs +++ b/rtcp/src/transport_feedbacks/transport_layer_cc/mod.rs @@ -507,10 +507,7 @@ impl Packet for TransportLayerCc { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/rtcp/src/transport_feedbacks/transport_layer_nack/mod.rs b/rtcp/src/transport_feedbacks/transport_layer_nack/mod.rs index 9482acd7e..dd63541de 100644 --- a/rtcp/src/transport_feedbacks/transport_layer_nack/mod.rs +++ b/rtcp/src/transport_feedbacks/transport_layer_nack/mod.rs @@ -154,10 +154,7 @@ impl Packet for TransportLayerNack { } fn equal(&self, other: &(dyn Packet + Send + Sync)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn cloned(&self) -> Box { diff --git a/srtp/src/session/mod.rs b/srtp/src/session/mod.rs index 81edefe32..491911aa2 100644 --- a/srtp/src/session/mod.rs +++ b/srtp/src/session/mod.rs @@ -28,6 +28,7 @@ const DEFAULT_SESSION_SRTCP_REPLAY_PROTECTION_WINDOW: usize = 64; pub struct Session { local_context: Arc>, streams_map: Arc>>>, + #[allow(clippy::type_complexity)] new_stream_rx: Arc, Option)>>>, close_stream_tx: mpsc::Sender, close_session_tx: mpsc::Sender<()>, diff --git a/turn/examples/turn_client_udp.rs b/turn/examples/turn_client_udp.rs index ed71976fd..725eb6798 100644 --- a/turn/examples/turn_client_udp.rs +++ b/turn/examples/turn_client_udp.rs @@ -185,7 +185,7 @@ async fn do_ping_test( // Send 10 packets from relay_conn to the echo server for _ in 0..2 { let msg = "12345678910".to_owned(); //format!("{:?}", tokio::time::Instant::now()); - println!("sending msg={} with size={}", msg, msg.as_bytes().len()); + println!("sending msg={} with size={}", msg, msg.len()); pinger_conn_tx.send_to(msg.as_bytes(), relay_addr).await?; // For simplicity, this example does not wait for the pong (reply). diff --git a/webrtc/src/rtp_transceiver/fmtp/generic/mod.rs b/webrtc/src/rtp_transceiver/fmtp/generic/mod.rs index 4b75ce350..4b62f2de2 100644 --- a/webrtc/src/rtp_transceiver/fmtp/generic/mod.rs +++ b/webrtc/src/rtp_transceiver/fmtp/generic/mod.rs @@ -53,10 +53,7 @@ impl Fmtp for GenericFmtp { } fn equal(&self, other: &(dyn Fmtp)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn as_any(&self) -> &(dyn Any) { diff --git a/webrtc/src/rtp_transceiver/fmtp/h264/mod.rs b/webrtc/src/rtp_transceiver/fmtp/h264/mod.rs index 22a5bf594..1d34302cf 100644 --- a/webrtc/src/rtp_transceiver/fmtp/h264/mod.rs +++ b/webrtc/src/rtp_transceiver/fmtp/h264/mod.rs @@ -90,10 +90,7 @@ impl Fmtp for H264Fmtp { } fn equal(&self, other: &(dyn Fmtp)) -> bool { - other - .as_any() - .downcast_ref::() - .map_or(false, |a| self == a) + other.as_any().downcast_ref::() == Some(self) } fn as_any(&self) -> &(dyn Any) {