From 76f780a622aee4937c7221049f2e62beb5addb74 Mon Sep 17 00:00:00 2001 From: yngrtc Date: Sat, 7 Sep 2024 11:33:16 -0700 Subject: [PATCH] fix clippy warning --- interceptor/src/nack/generator/mod.rs | 6 +----- interceptor/src/nack/responder/mod.rs | 6 +----- rtcp/src/raw_packet.rs | 5 +---- turn/src/server/request.rs | 6 +----- util/src/vnet/net.rs | 5 +---- 5 files changed, 5 insertions(+), 23 deletions(-) diff --git a/interceptor/src/nack/generator/mod.rs b/interceptor/src/nack/generator/mod.rs index 93d13dac4..74a0a5d35 100644 --- a/interceptor/src/nack/generator/mod.rs +++ b/interceptor/src/nack/generator/mod.rs @@ -56,11 +56,7 @@ impl InterceptorBuilder for GeneratorBuilder { let (close_tx, close_rx) = mpsc::channel(1); Ok(Arc::new(Generator { internal: Arc::new(GeneratorInternal { - log2_size_minus_6: if let Some(log2_size_minus_6) = self.log2_size_minus_6 { - log2_size_minus_6 - } else { - 13 - 6 // 8192 = 1 << 13 - }, + log2_size_minus_6: self.log2_size_minus_6.unwrap_or(13 - 6), // 8192 = 1 << 13 skip_last_n: self.skip_last_n.unwrap_or_default(), interval: if let Some(interval) = self.interval { interval diff --git a/interceptor/src/nack/responder/mod.rs b/interceptor/src/nack/responder/mod.rs index 934a948a2..3b668193b 100644 --- a/interceptor/src/nack/responder/mod.rs +++ b/interceptor/src/nack/responder/mod.rs @@ -38,11 +38,7 @@ impl InterceptorBuilder for ResponderBuilder { fn build(&self, _id: &str) -> Result> { Ok(Arc::new(Responder { internal: Arc::new(ResponderInternal { - log2_size: if let Some(log2_size) = self.log2_size { - log2_size - } else { - 13 // 8192 = 1 << 13 - }, + log2_size: self.log2_size.unwrap_or(13), // 8192 = 1 << 13 streams: Arc::new(Mutex::new(HashMap::new())), }), })) diff --git a/rtcp/src/raw_packet.rs b/rtcp/src/raw_packet.rs index 68b8cd870..dc5fc78d5 100644 --- a/rtcp/src/raw_packet.rs +++ b/rtcp/src/raw_packet.rs @@ -23,10 +23,7 @@ impl fmt::Display for RawPacket { impl Packet for RawPacket { /// Header returns the Header associated with this packet. fn header(&self) -> Header { - match Header::unmarshal(&mut self.0.clone()) { - Ok(h) => h, - Err(_) => Header::default(), - } + Header::unmarshal(&mut self.0.clone()).unwrap_or_default() } /// destination_ssrc returns an array of SSRC values that this packet refers to. diff --git a/turn/src/server/request.rs b/turn/src/server/request.rs index 9d1a3104f..2cb773f6e 100644 --- a/turn/src/server/request.rs +++ b/turn/src/server/request.rs @@ -952,11 +952,7 @@ pub(crate) fn rand_seq(n: usize) -> String { for b in &mut buf { *b = letters[rand::random::() % letters.len()]; } - if let Ok(s) = String::from_utf8(buf) { - s - } else { - String::new() - } + String::from_utf8(buf).unwrap_or_default() } pub(crate) fn build_nonce() -> Result { diff --git a/util/src/vnet/net.rs b/util/src/vnet/net.rs index 5586e59b7..dd9bf478e 100644 --- a/util/src/vnet/net.rs +++ b/util/src/vnet/net.rs @@ -445,10 +445,7 @@ impl Net { Net::VNet(Arc::new(Mutex::new(vnet))) } else { - let interfaces = match ifaces::ifaces() { - Ok(ifs) => ifs, - Err(_) => vec![], - }; + let interfaces = ifaces::ifaces().unwrap_or_default(); let mut m: HashMap> = HashMap::new(); for iface in interfaces {