Skip to content

refactor: apply clippy fixes across workspace #703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/src/data_channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl DataChannel {
match self.handle_dcep(&mut data).await {
Ok(()) => {}
Err(err) => {
log::error!("Failed to handle DCEP: {:?}", err);
log::error!("Failed to handle DCEP: {err:?}");
}
}
continue;
Expand Down
2 changes: 1 addition & 1 deletion dtls/src/conn/conn_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2302,7 +2302,7 @@ async fn test_multiple_hello_verify_request() -> Result<()> {

for i in 0..cookies.len() {
let cookie = &cookies[i];
trace!("cookie {}: {:?}", i, cookie);
trace!("cookie {i}: {cookie:?}");

// read client hello
let mut resp = vec![0; 1024];
Expand Down
2 changes: 1 addition & 1 deletion dtls/src/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ fn verify_signature(
_ => return Err(Error::ErrKeySignatureVerifyUnimplemented),
};

log::trace!("Picked an algorithm {:?}", verify_alg);
log::trace!("Picked an algorithm {verify_alg:?}");

let public_key = ring::signature::UnparsedPublicKey::new(
verify_alg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async fn main() -> anyhow::Result<()> {
if let Ok(candidate) = candidate.to_json() {
if let Some(requester) = maybe_requester.upgrade() {
if let Err(err) = requester.add_ice_candidate(candidate).await {
log::warn!("{}", err);
log::warn!("{err}");
}
}
}
Expand All @@ -191,7 +191,7 @@ async fn main() -> anyhow::Result<()> {
if let Ok(candidate) = candidate.to_json() {
if let Some(responder) = maybe_responder.upgrade() {
if let Err(err) = responder.add_ice_candidate(candidate).await {
log::warn!("{}", err);
log::warn!("{err}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async fn main() -> Result<()> {
let (answer_sdr, answer_rcv) = mpsc::channel::<RTCSessionDescription>(10);
tokio::spawn(async move {
if let Err(e) = offer_worker(video_file1, audio_file, offer_sdr, answer_rcv).await {
println!("[Speaker] Error: {:?}", e);
println!("[Speaker] Error: {e:?}");
}
});
// Create a MediaEngine object to configure the supported codec
Expand Down
6 changes: 2 additions & 4 deletions ice/src/agent/agent_gather.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl Agent {
.await;

if let Err(err) = result {
log::error!("Failed to gather local candidates using UDP mux: {}", err);
log::error!("Failed to gather local candidates using UDP mux: {err}");
}

return;
Expand Down Expand Up @@ -426,9 +426,7 @@ impl Agent {
Ok(ip) => Some(ip),
Err(err) => {
log::warn!(
"1:1 NAT mapping is enabled but not external IP is found for {}: {}",
ip,
err
"1:1 NAT mapping is enabled but not external IP is found for {ip}: {err}"
);
None
}
Expand Down
5 changes: 1 addition & 4 deletions ice/src/agent/agent_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,7 @@ impl AgentInternal {
}

log::debug!(
"Started agent: isControlling? {}, remoteUfrag: {}, remotePwd: {}",
is_controlling,
remote_ufrag,
remote_pwd
"Started agent: isControlling? {is_controlling}, remoteUfrag: {remote_ufrag}, remotePwd: {remote_pwd}"
);
self.set_remote_credentials(remote_ufrag, remote_pwd)
.await?;
Expand Down
29 changes: 9 additions & 20 deletions ice/src/agent/agent_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl AgentInternal {
};

if let Err(err) = result {
log::error!("{}", err);
log::error!("{err}");
None
} else {
log::trace!(
Expand Down Expand Up @@ -297,7 +297,7 @@ impl ControllingSelector for AgentInternal {
};

if let Err(err) = result {
log::error!("{}", err);
log::error!("{err}");
} else {
self.send_binding_request(&msg, local, remote).await;
}
Expand All @@ -316,15 +316,11 @@ impl ControllingSelector for AgentInternal {
// Assert that NAT is not symmetric
// https://tools.ietf.org/html/rfc8445#section-7.2.5.2.1
if transaction_addr != remote_addr {
log::debug!("discard message: transaction source and destination does not match expected({}), actual({})", transaction_addr, remote);
log::debug!("discard message: transaction source and destination does not match expected({transaction_addr}), actual({remote})");
return;
}

log::trace!(
"inbound STUN (SuccessResponse) from {} to {}",
remote,
local
);
log::trace!("inbound STUN (SuccessResponse) from {remote} to {local}");
let selected_pair_is_none = self.agent_conn.get_selected_pair().is_none();

if let Some(p) = self.find_pair(local, remote).await {
Expand Down Expand Up @@ -380,10 +376,7 @@ impl ControllingSelector for AgentInternal {
&& self.agent_conn.get_selected_pair().is_none()
{
if let Some(best_pair) = self.agent_conn.get_best_available_candidate_pair().await {
log::trace!(
"controllingSelector: getBestAvailableCandidatePair {}",
best_pair
);
log::trace!("controllingSelector: getBestAvailableCandidatePair {best_pair}");
if best_pair == p
&& self.is_nominatable(&p.local)
&& self.is_nominatable(&p.remote)
Expand Down Expand Up @@ -449,7 +442,7 @@ impl ControlledSelector for AgentInternal {
};

if let Err(err) = result {
log::error!("{}", err);
log::error!("{err}");
} else {
self.send_binding_request(&msg, local, remote).await;
}
Expand All @@ -474,20 +467,16 @@ impl ControlledSelector for AgentInternal {
// Assert that NAT is not symmetric
// https://tools.ietf.org/html/rfc8445#section-7.2.5.2.1
if transaction_addr != remote_addr {
log::debug!("discard message: transaction source and destination does not match expected({}), actual({})", transaction_addr, remote);
log::debug!("discard message: transaction source and destination does not match expected({transaction_addr}), actual({remote})");
return;
}

log::trace!(
"inbound STUN (SuccessResponse) from {} to {}",
remote,
local
);
log::trace!("inbound STUN (SuccessResponse) from {remote} to {local}");

if let Some(p) = self.find_pair(local, remote).await {
p.state
.store(CandidatePairState::Succeeded as u8, Ordering::SeqCst);
log::trace!("Found valid candidate pair: {}", p);
log::trace!("Found valid candidate pair: {p}");

if p.nominate_on_binding_success.load(Ordering::SeqCst)
&& self.agent_conn.get_selected_pair().is_none()
Expand Down
8 changes: 4 additions & 4 deletions ice/src/agent/agent_vnet_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,8 @@ async fn test_connectivity_vnet_1to1_nat_with_host_candidate_vs_symmetric_nats()
filtering_behavior: nat::EndpointDependencyType::EndpointAddrPortDependent,
..Default::default()
};
log::debug!("natType0: {:?}", nat_type0);
log::debug!("natType1: {:?}", nat_type1);
log::debug!("natType0: {nat_type0:?}");
log::debug!("natType1: {nat_type1:?}");

let v = build_vnet(nat_type0, nat_type1).await?;

Expand Down Expand Up @@ -711,8 +711,8 @@ async fn test_connectivity_vnet_1to1_nat_with_srflx_candidate_vs_symmetric_nats(
filtering_behavior: nat::EndpointDependencyType::EndpointAddrPortDependent,
..Default::default()
};
log::debug!("natType0: {:?}", nat_type0);
log::debug!("natType1: {:?}", nat_type1);
log::debug!("natType0: {nat_type0:?}");
log::debug!("natType1: {nat_type1:?}");

let v = build_vnet(nat_type0, nat_type1).await?;

Expand Down
6 changes: 3 additions & 3 deletions ice/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl Agent {
Err(err) => {
// Opportunistic mDNS: If we can't open the connection, that's ok: we
// can continue without it.
log::warn!("Failed to initialize mDNS {}: {}", mdns_name, err);
log::warn!("Failed to initialize mDNS {mdns_name}: {err}");
None
}
};
Expand Down Expand Up @@ -269,7 +269,7 @@ impl Agent {
if c.tcp_type() == TcpType::Active {
// TCP Candidates with tcptype active will probe server passive ones, so
// no need to do anything with them.
log::info!("Ignoring remote candidate with tcpType active: {}", c);
log::info!("Ignoring remote candidate with tcpType active: {c}");
return Ok(());
}

Expand Down Expand Up @@ -515,7 +515,7 @@ impl Agent {
async fn close_multicast_conn(mdns_conn: &Option<Arc<DnsConn>>) {
if let Some(conn) = mdns_conn {
if let Err(err) = conn.close().await {
log::warn!("failed to close mDNS Conn: {}", err);
log::warn!("failed to close mDNS Conn: {err}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ice/src/mdns/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub(crate) fn create_multicast_dns(
} else {
SocketAddr::from_str(dest_addr)?
};
log::info!("mDNS is using {} as dest_addr", addr);
log::info!("mDNS is using {addr} as dest_addr");

let conn = DnsConn::server(
addr,
Expand Down
13 changes: 5 additions & 8 deletions ice/src/udp_mux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl UDPMuxDefault {

match result {
Err(err) => {
log::warn!("Failed to handle decode ICE from {}: {}", addr, err);
log::warn!("Failed to handle decode ICE from {addr}: {err}");
None
}
Ok(_) => {
Expand All @@ -139,10 +139,7 @@ impl UDPMuxDefault {
// Per the RFC this shouldn't happen
// https://datatracker.ietf.org/doc/html/rfc5389#section-15.3
Err(err) => {
log::warn!(
"Failed to decode USERNAME from STUN message as UTF-8: {}",
err
);
log::warn!("Failed to decode USERNAME from STUN message as UTF-8: {err}");
return None;
}
Ok(s) => s,
Expand Down Expand Up @@ -197,14 +194,14 @@ impl UDPMuxDefault {
}
Some(conn) => {
if let Err(err) = conn.write_packet(&buffer[..len], addr).await {
log::error!("Failed to write packet: {}", err);
log::error!("Failed to write packet: {err}");
}
}
}
}
Err(Error::Io(err)) if err.0.kind() == ErrorKind::TimedOut => continue,
Err(err) => {
log::error!("Could not read udp packet: {}", err);
log::error!("Could not read udp packet: {err}");
break;
}
}
Expand Down Expand Up @@ -325,7 +322,7 @@ impl UDPMuxWriter for UDPMuxDefault {
.or_insert_with(|| conn.clone());
}

log::debug!("Registered {} for {}", addr, key);
log::debug!("Registered {addr} for {key}");
}

async fn send_to(&self, buf: &[u8], target: &SocketAddr) -> Result<usize, Error> {
Expand Down
12 changes: 6 additions & 6 deletions ice/src/udp_mux/udp_mux_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async fn test_udp_mux() -> Result<()> {
let udp_socket = UdpSocket::bind((std::net::Ipv4Addr::UNSPECIFIED, 0)).await?;

let addr = udp_socket.local_addr()?;
log::info!("Listening on {}", addr);
log::info!("Listening on {addr}");

let udp_mux = UDPMuxDefault::new(UDPMuxParams::new(udp_socket));
let udp_mux_dyn = Arc::clone(&udp_mux) as Arc<dyn UDPMux + Send + Sync>;
Expand Down Expand Up @@ -164,9 +164,9 @@ async fn test_mux_connection(
.unwrap();

let remote_connection = Arc::new(network.bind().await?);
log::info!("Bound for ufrag: {}", ufrag);
log::info!("Bound for ufrag: {ufrag}");
remote_connection.connect(connect_addr).await?;
log::info!("Connected to {} for ufrag: {}", connect_addr, ufrag);
log::info!("Connected to {connect_addr} for ufrag: {ufrag}");
log::info!(
"Testing muxing from {} over {}",
remote_connection.local_addr().unwrap(),
Expand Down Expand Up @@ -222,7 +222,7 @@ async fn test_mux_connection(
.expect("Failed to write to muxxed connection");

read += n;
log::debug!("Muxxed read {}, sequence: {}", read, next_sequence);
log::debug!("Muxxed read {read}, sequence: {next_sequence}");
next_sequence += 1;
}
});
Expand All @@ -243,7 +243,7 @@ async fn test_mux_connection(

verify_packet(&buffer[..n], next_sequence);
read += n;
log::debug!("Remote read {}, sequence: {}", read, next_sequence);
log::debug!("Remote read {read}, sequence: {next_sequence}");
next_sequence += 1;
}
});
Expand All @@ -261,7 +261,7 @@ async fn test_mux_connection(
let len = remote_connection.send(&buffer).await?;

written += len;
log::debug!("Data written {}, sequence: {}", written, sequence);
log::debug!("Data written {written}, sequence: {sequence}");
sequence += 1;

sleep(Duration::from_millis(1)).await;
Expand Down
2 changes: 1 addition & 1 deletion ice/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub async fn listen_udp_in_port_range(
let laddr = SocketAddr::new(laddr.ip(), port_current);
match vnet.bind(laddr).await {
Ok(c) => return Ok(c),
Err(err) => log::debug!("failed to listen {}: {}", laddr, err),
Err(err) => log::debug!("failed to listen {laddr}: {err}"),
};

port_current += 1;
Expand Down
5 changes: 1 addition & 4 deletions ice/src/util/util_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ async fn test_local_interfaces() -> Result<()> {
assert!(!ips.iter().any(|ip| ip.is_loopback()));
assert!(ips_with_loopback.iter().any(|ip| ip.is_loopback()));
log::info!(
"interfaces: {:?}, ips: {:?}, ips_with_loopback: {:?}",
interfaces,
ips,
ips_with_loopback
"interfaces: {interfaces:?}, ips: {ips:?}, ips_with_loopback: {ips_with_loopback:?}"
);
Ok(())
}
4 changes: 2 additions & 2 deletions interceptor/src/nack/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl Generator {
let a = Attributes::new();
for nack in nacks{
if let Err(err) = rtcp_writer.write(&[Box::new(nack)], &a).await{
log::warn!("failed sending nack: {}", err);
log::warn!("failed sending nack: {err}");
}
}
}
Expand Down Expand Up @@ -183,7 +183,7 @@ impl Interceptor for Generator {
tokio::spawn(async move {
let _d = w.take();
if let Err(err) = Generator::run(writer2, internal).await {
log::warn!("bind_rtcp_writer NACK Generator::run got error: {}", err);
log::warn!("bind_rtcp_writer NACK Generator::run got error: {err}");
}
});

Expand Down
2 changes: 1 addition & 1 deletion interceptor/src/nack/responder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl ResponderInternal {
if let Some(p) = stream3.get(seq).await {
let a = Attributes::new();
if let Err(err) = stream3.next_rtp_writer.write(&p, &a).await {
log::warn!("failed resending nacked packet: {}", err);
log::warn!("failed resending nacked packet: {err}");
}
}
true
Expand Down
4 changes: 2 additions & 2 deletions interceptor/src/report/receiver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl ReceiverReport {

let a = Attributes::new();
if let Err(err) = rtcp_writer.write(&[Box::new(pkt)], &a).await{
log::warn!("failed sending: {}", err);
log::warn!("failed sending: {err}");
}
}
}
Expand Down Expand Up @@ -159,7 +159,7 @@ impl Interceptor for ReceiverReport {
tokio::spawn(async move {
let _d = w.take();
if let Err(err) = ReceiverReport::run(writer2, internal).await {
log::warn!("bind_rtcp_writer ReceiverReport::run got error: {}", err);
log::warn!("bind_rtcp_writer ReceiverReport::run got error: {err}");
}
});

Expand Down
Loading
Loading