Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumEntangledAndy committed Oct 26, 2024
1 parent 4f8fb6c commit ed4a5ea
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 57 deletions.
25 changes: 3 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions crates/core/src/bc/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 3 additions & 8 deletions crates/core/src/bc/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<u32>,
}

#[derive(Debug)]
pub(crate) struct BcContext {
pub(crate) credentials: Credentials,
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/bc_protocol/connection/bcsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub struct BcStream<'a> {
rx: &'a mut ReceiverStream<Result<Bc>>,
}

impl<'a> Unpin for BcStream<'a> {}
impl Unpin for BcStream<'_> {}

impl<'a> Stream for BcStream<'a> {
impl Stream for BcStream<'_> {
type Item = Result<Bc>;

fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Bc>>> {
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/bc_protocol/resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl ToSocketAddrsOrUid for SocketAddrV6 {
}
}

impl<'a> ToSocketAddrsOrUid for &'a [SocketAddr] {
impl ToSocketAddrsOrUid for &'_ [SocketAddr] {
type UidIter = std::vec::IntoIter<SocketAddrOrUid>;

fn to_socket_addrs_or_uid(&self) -> Result<Self::UidIter, Error> {
Expand Down
9 changes: 0 additions & 9 deletions crates/core/src/bcudp/codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<Self::Item>> {
// match self.decode(buf)? {
// Some(frame) => Ok(Some(frame)),
// None => Ok(None),
// }
// }

fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>> {
log::trace!("Decoding:");
if src.is_empty() {
Expand Down
8 changes: 0 additions & 8 deletions crates/mailnoti/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ async fn main() -> Result<()> {
Ok(())
}

fn get_local_ip() -> Result<std::net::IpAddr> {
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) {
Expand Down
3 changes: 1 addition & 2 deletions src/common/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -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?;
Expand Down
2 changes: 1 addition & 1 deletion src/mqtt/mqttc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit ed4a5ea

Please sign in to comment.