diff --git a/crates/core/src/bc/de.rs b/crates/core/src/bc/de.rs index 1943cfb..4b5ebc9 100644 --- a/crates/core/src/bc/de.rs +++ b/crates/core/src/bc/de.rs @@ -169,8 +169,7 @@ fn bc_modern_msg<'a, 'b>( }; // Now we'll take the buffer that Nom gave a ref to and parse it. - let extension; - if ext_len > 0 { + let extension = if ext_len > 0 { // Apply the XML parse function, but throw away the reference to decrypted in the Ok and // Err case. This error-error-error thing is the same idiom Nom uses internally. let parsed = Extension::try_parse(processed_ext_buf) @@ -182,10 +181,10 @@ fn bc_modern_msg<'a, 'b>( { context.in_bin_mode.insert(header.msg_num); } - extension = Some(parsed); + Some(parsed) } else { - extension = None; - } + None + }; // Now to handle the payload block // This block can either be xml or binary depending on what the message expects. diff --git a/crates/core/src/bc/ser.rs b/crates/core/src/bc/ser.rs index f2770ff..ee749cd 100644 --- a/crates/core/src/bc/ser.rs +++ b/crates/core/src/bc/ser.rs @@ -173,7 +173,7 @@ where /// A serializer combinator that does nothing with its input fn do_nothing() -> impl SerializeFn { - move |out: WriteContext| Ok(out) + Ok } #[test] diff --git a/crates/core/src/bc/xml.rs b/crates/core/src/bc/xml.rs index 908bb41..ce0f1d0 100644 --- a/crates/core/src/bc/xml.rs +++ b/crates/core/src/bc/xml.rs @@ -12,6 +12,7 @@ use indoc::indoc; /// There are two types of payloads xml and binary #[derive(PartialEq, Eq, Debug, YaDeserialize)] #[yaserde(flatten)] +#[allow(clippy::large_enum_variant)] pub enum BcPayloads { /// XML payloads are the more common ones and include payloads for camera controls #[yaserde(rename = "body")] diff --git a/crates/core/src/bc_protocol/connection/udpconn/discover.rs b/crates/core/src/bc_protocol/connection/udpconn/discover.rs index f17c805..aabb873 100644 --- a/crates/core/src/bc_protocol/connection/udpconn/discover.rs +++ b/crates/core/src/bc_protocol/connection/udpconn/discover.rs @@ -40,12 +40,11 @@ impl UdpDiscover { let addrs: Vec = addrs .iter() - .map(|a| { + .flat_map(|a| { a.to_socket_addrs() .ok() .and_then(|mut a_iter| a_iter.next()) }) - .flatten() .collect(); let mut bytes_send = 0; @@ -120,13 +119,12 @@ impl UdpDiscover { let ports: [u16; 2] = [2015, 2018]; let destinations: Vec<(Ipv4Addr, u16)> = broadcasts .iter() - .map(|&addr| { + .flat_map(|&addr| { ports .iter() .map(|&port| (addr, port)) .collect::>() }) - .flatten() .collect(); debug!("Broadcasting to: {:?}", destinations); diff --git a/crates/core/src/bcmedia/de.rs b/crates/core/src/bcmedia/de.rs index 2d4627c..d563872 100644 --- a/crates/core/src/bcmedia/de.rs +++ b/crates/core/src/bcmedia/de.rs @@ -87,7 +87,7 @@ where impl BcMedia { pub(crate) fn deserialize(r: R) -> Result { // Throw away the nom-specific return types - read_from_reader(|reader| bcmedia(reader), r) + read_from_reader(bcmedia, r) } } diff --git a/crates/core/src/bcudp/de.rs b/crates/core/src/bcudp/de.rs index ab4479c..a691f32 100644 --- a/crates/core/src/bcudp/de.rs +++ b/crates/core/src/bcudp/de.rs @@ -84,7 +84,7 @@ where impl BcUdp { pub(crate) fn deserialize(r: R) -> Result { // Throw away the nom-specific return types - read_from_reader(|reader| bcudp(reader), r) + read_from_reader(bcudp, r) } } diff --git a/crates/core/src/bcudp/model.rs b/crates/core/src/bcudp/model.rs index b82c2d5..ecdd6d5 100644 --- a/crates/core/src/bcudp/model.rs +++ b/crates/core/src/bcudp/model.rs @@ -5,6 +5,7 @@ use super::xml::*; /// Top level udp packet #[derive(Debug, PartialEq, Eq)] +#[allow(clippy::large_enum_variant)] pub enum BcUdp { /// Packet from the negotiate stage when connection info is exchanged Discovery(UdpDiscovery), diff --git a/crates/core/src/bcudp/xml_crypto.rs b/crates/core/src/bcudp/xml_crypto.rs index 147f575..e5e69ef 100644 --- a/crates/core/src/bcudp/xml_crypto.rs +++ b/crates/core/src/bcudp/xml_crypto.rs @@ -5,8 +5,7 @@ const XML_KEY: [u32; 8] = [ pub(crate) fn decrypt(offset: u32, buf: &[u8]) -> Vec { let key = XML_KEY .iter() - .map(|i| (i + offset).to_le_bytes()) - .flatten() + .flat_map(|i| (i + offset).to_le_bytes()) .cycle(); buf.iter().zip(key).map(|(byte, key)| key ^ byte).collect() } diff --git a/src/rtsp/gst.rs b/src/rtsp/gst.rs index 2955c07..4f052d5 100644 --- a/src/rtsp/gst.rs +++ b/src/rtsp/gst.rs @@ -347,7 +347,7 @@ mod maybe_app_src { /// owning the AppSrc directly. This function handles either case and returns the AppSrc, /// or None if the caller has not yet sent one. fn try_get_src(&mut self) -> Option<&AppSrc> { - while let Some(src) = self.rx.try_recv().ok() { + while let Ok(src) = self.rx.try_recv() { self.app_src = Some(src); } self.app_src.as_ref()