From ed4a5ea001e31ebd1b06215effb083f673f40a67 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Sat, 26 Oct 2024 14:33:19 +0700 Subject: [PATCH] Style fixes --- Cargo.lock | 25 +++---------------- crates/core/src/bc/de.rs | 6 ++--- crates/core/src/bc/model.rs | 11 +++----- .../core/src/bc_protocol/connection/bcsub.rs | 4 +-- crates/core/src/bc_protocol/resolution.rs | 2 +- crates/core/src/bcudp/codex.rs | 9 ------- crates/mailnoti/src/main.rs | 8 ------ src/common/instance.rs | 3 +-- src/mqtt/mqttc.rs | 2 +- 9 files changed, 13 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 567f61f..c0e32a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -839,25 +839,6 @@ dependencies = [ "webpki-roots", ] -[[package]] -name = "fcm-push-listener" -version = "3.0.0" -dependencies = [ - "base64 0.21.7", - "ece", - "log", - "prost", - "prost-build", - "rand", - "reqwest", - "serde", - "serde_with", - "tokio", - "tokio-rustls 0.23.4", - "uuid", - "webpki-roots", -] - [[package]] name = "fixedbitset" version = "0.4.2" @@ -1895,7 +1876,7 @@ dependencies = [ "crossbeam-channel", "dirs", "env_logger 0.11.3", - "fcm-push-listener 2.0.3", + "fcm-push-listener", "futures", "gstreamer", "gstreamer-app", @@ -2339,7 +2320,7 @@ dependencies = [ "anyhow", "clap", "env_logger 0.10.2", - "fcm-push-listener 2.0.3", + "fcm-push-listener", "lazy_static", "log", "neolink_core", diff --git a/crates/core/src/bc/de.rs b/crates/core/src/bc/de.rs index d8da749..182bcc7 100644 --- a/crates/core/src/bc/de.rs +++ b/crates/core/src/bc/de.rs @@ -90,10 +90,8 @@ fn bc_modern_msg<'a>( E::add_context(input, ctx, E::from_error_kind(input, kind)) } - let ext_len = match header.payload_offset { - Some(off) => off, - _ => 0, // If missing payload_offset treat all as payload - }; + // If missing payload_offset treat all as payload + let ext_len = header.payload_offset.unwrap_or_default(); let (buf, ext_buf) = take(ext_len)(buf)?; let payload_len = header.body_len - ext_len; diff --git a/crates/core/src/bc/model.rs b/crates/core/src/bc/model.rs index 2e8dd05..6449fb3 100644 --- a/crates/core/src/bc/model.rs +++ b/crates/core/src/bc/model.rs @@ -192,8 +192,11 @@ pub struct BcMeta { pub stream_type: u8, /// On modern messages this is the response code /// When sending a command it is set to `0`. The reply from the camera can be + /// /// - `200` for OK + /// /// - `400` for bad request + /// /// A malformed packet will return a `400` code pub response_code: u16, /// A message ID is used to match replies with requests. The camera will parrot back @@ -213,14 +216,6 @@ pub struct BcMeta { pub class: u16, } -/// The components of the Baichuan header that must be filled out after the body is serialized, or -/// is needed for the deserialization of the body (strictly part of the wire format of the message) -#[derive(Debug, PartialEq, Eq)] -pub(super) struct BcSendInfo { - pub body_len: u32, - pub payload_offset: Option, -} - #[derive(Debug)] pub(crate) struct BcContext { pub(crate) credentials: Credentials, diff --git a/crates/core/src/bc_protocol/connection/bcsub.rs b/crates/core/src/bc_protocol/connection/bcsub.rs index 8933535..6f8d21c 100644 --- a/crates/core/src/bc_protocol/connection/bcsub.rs +++ b/crates/core/src/bc_protocol/connection/bcsub.rs @@ -20,9 +20,9 @@ pub struct BcStream<'a> { rx: &'a mut ReceiverStream>, } -impl<'a> Unpin for BcStream<'a> {} +impl Unpin for BcStream<'_> {} -impl<'a> Stream for BcStream<'a> { +impl Stream for BcStream<'_> { type Item = Result; fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll>> { diff --git a/crates/core/src/bc_protocol/resolution.rs b/crates/core/src/bc_protocol/resolution.rs index 17e99b2..1fb308b 100644 --- a/crates/core/src/bc_protocol/resolution.rs +++ b/crates/core/src/bc_protocol/resolution.rs @@ -214,7 +214,7 @@ impl ToSocketAddrsOrUid for SocketAddrV6 { } } -impl<'a> ToSocketAddrsOrUid for &'a [SocketAddr] { +impl ToSocketAddrsOrUid for &'_ [SocketAddr] { type UidIter = std::vec::IntoIter; fn to_socket_addrs_or_uid(&self) -> Result { diff --git a/crates/core/src/bcudp/codex.rs b/crates/core/src/bcudp/codex.rs index fb54e6e..d612dc4 100644 --- a/crates/core/src/bcudp/codex.rs +++ b/crates/core/src/bcudp/codex.rs @@ -34,15 +34,6 @@ impl Decoder for BcUdpCodex { type Item = BcUdp; type Error = Error; - /// Since frames can cross EOF boundaries we overload this so it doesn't error if - /// there are bytes left on the stream - // fn decode_eof(&mut self, buf: &mut BytesMut) -> Result> { - // match self.decode(buf)? { - // Some(frame) => Ok(Some(frame)), - // None => Ok(None), - // } - // } - fn decode(&mut self, src: &mut BytesMut) -> Result> { log::trace!("Decoding:"); if src.is_empty() { diff --git a/crates/mailnoti/src/main.rs b/crates/mailnoti/src/main.rs index 4ffc54e..a223a73 100644 --- a/crates/mailnoti/src/main.rs +++ b/crates/mailnoti/src/main.rs @@ -53,14 +53,6 @@ async fn main() -> Result<()> { Ok(()) } -fn get_local_ip() -> Result { - get_if_addrs::get_if_addrs()? - .iter() - .find(|i| !i.is_loopback() && matches!(i.addr, get_if_addrs::IfAddr::V4(_))) - .map(|iface| Ok(iface.ip())) - .unwrap_or_else(|| Err(anyhow!("No Local Ip Address Found"))) -} - async fn cam_tasks(name: &str, camera: BcCamera, addr: SocketAddr) -> Result<()> { let support = camera.get_support().await?; if support.email.is_some_and(|v| v > 0) { diff --git a/src/common/instance.rs b/src/common/instance.rs index f3ecfc6..4b5811d 100644 --- a/src/common/instance.rs +++ b/src/common/instance.rs @@ -26,7 +26,6 @@ use neolink_core::{ bc_protocol::{BcCamera, StreamKind}, bcmedia::model::BcMedia, }; -#[cfg(feature = "gstreamer")] /// This instance is the primary interface used throughout the app /// @@ -423,7 +422,7 @@ impl NeoInstance { }), )); - #[cfg(pushnoti)] + #[cfg(feature = "pushnoti")] { // Creates a permit for controlling based on the PN let pn_permit = counter.create_deactivated().await?; diff --git a/src/mqtt/mqttc.rs b/src/mqtt/mqttc.rs index c7f8d06..f82ec70 100644 --- a/src/mqtt/mqttc.rs +++ b/src/mqtt/mqttc.rs @@ -339,7 +339,7 @@ impl<'a> MqttBackend<'a> { } } -impl<'a> Drop for MqttBackend<'a> { +impl Drop for MqttBackend<'_> { fn drop(&mut self) { self.cancel.cancel(); }