diff --git a/src/bc/media_packet.rs b/src/bc/media_packet.rs index f592ef2..3d2c333 100644 --- a/src/bc/media_packet.rs +++ b/src/bc/media_packet.rs @@ -80,9 +80,7 @@ impl MediaData { MediaDataKind::AudioDataAac => MediaData::bytes_to_size(&data[4..6]), MediaDataKind::AudioDataAdpcm => MediaData::bytes_to_size(&data[4..6]), MediaDataKind::InfoData => MediaData::bytes_to_size(&data[4..8]), - MediaDataKind::Unknown | MediaDataKind::Invalid | MediaDataKind::Continue => { - data.len() - } + MediaDataKind::Unknown | MediaDataKind::Invalid | MediaDataKind::Continue => data.len(), } } diff --git a/src/bc/mod.rs b/src/bc/mod.rs index 15603e4..adc850e 100644 --- a/src/bc/mod.rs +++ b/src/bc/mod.rs @@ -10,8 +10,8 @@ //! All message IDs start out as XML, but can be statefully switched to binary with a special XML //! "Extension" message. -pub mod model; pub mod media_packet; +pub mod model; pub mod de; pub mod ser; diff --git a/src/bc_protocol.rs b/src/bc_protocol.rs index 1f55458..8fa5fbb 100644 --- a/src/bc_protocol.rs +++ b/src/bc_protocol.rs @@ -1,7 +1,7 @@ use self::connection::BcConnection; use crate::bc; -use crate::bc::{model::*, xml::*}; use crate::bc::media_packet::*; +use crate::bc::{model::*, xml::*}; use err_derive::Error; use log::*; use md5; diff --git a/src/bc_protocol/connection.rs b/src/bc_protocol/connection.rs index aa7627c..648588c 100644 --- a/src/bc_protocol/connection.rs +++ b/src/bc_protocol/connection.rs @@ -1,19 +1,23 @@ use crate::bc; -use crate::bc::model::*; use crate::bc::media_packet::*; +use crate::bc::model::*; use err_derive::Error; use log::*; use socket2::{Domain, Socket, Type}; use std::collections::btree_map::Entry; use std::collections::BTreeMap; +use std::collections::VecDeque; use std::net::{Shutdown, SocketAddr, TcpStream}; use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::{Arc, Mutex}; use std::thread::JoinHandle; use std::time::Duration; -use std::collections::VecDeque; -const INVALID_MEDIA_PACKETS: &[MediaDataKind] = &[MediaDataKind::Invalid, MediaDataKind::Continue, MediaDataKind::Unknown]; +const INVALID_MEDIA_PACKETS: &[MediaDataKind] = &[ + MediaDataKind::Invalid, + MediaDataKind::Continue, + MediaDataKind::Unknown, +]; /// A shareable connection to a camera. Handles serialization of messages. To send/receive, call /// .subscribe() with a message ID. You can use the BcSubscription to send or receive only @@ -245,8 +249,8 @@ impl<'a> BcSubscription<'a> { // Pop the full binary buffer let binary = self.binary_buffer.drain(..full_size); - Ok(MediaData{ - data: binary.collect() + Ok(MediaData { + data: binary.collect(), }) } diff --git a/src/bc_protocol/time.rs b/src/bc_protocol/time.rs index 7b97c20..8777f34 100644 --- a/src/bc_protocol/time.rs +++ b/src/bc_protocol/time.rs @@ -41,21 +41,22 @@ impl BcCamera { .. }) = msg.body { - let datetime = match try_build_timestamp( - time_zone, year, month, day, hour, minute, second - ) { - Ok(dt) => dt, - Err(e) => return Err(Error::UnintelligibleReply { - reply: msg, - why: "Could not parse date", - }) - }; + let datetime = + match try_build_timestamp(time_zone, year, month, day, hour, minute, second) { + Ok(dt) => dt, + Err(e) => { + return Err(Error::UnintelligibleReply { + reply: msg, + why: "Could not parse date", + }) + } + }; // This code was written in 2020; I'm trying to catch all the possible epochs that // cameras might reset themselves to. My B800 resets to Jan 1, 1999, but I can't // guarantee that Reolink won't pick some newer date. Therefore, last year ought // to be new enough, yet still distant enough that it won't interfere with anything - const BOUNDARY: Date = date!(2019-01-01); + const BOUNDARY: Date = date!(2019 - 01 - 01); // detect if no time is actually set, and return Ok(None): that is, operation // succeeded, and there is no time set diff --git a/src/gst.rs b/src/gst.rs index cfa178d..47d9521 100644 --- a/src/gst.rs +++ b/src/gst.rs @@ -168,8 +168,7 @@ impl RtspServer { // We seperate reading the file and changing to a PEM so that we get different error messages. let cert_contents = fs::read_to_string(cert_file).expect("TLS file not found"); - let cert = - TlsCertificate::from_pem(&cert_contents).expect("Not a valid TLS certificate"); + let cert = TlsCertificate::from_pem(&cert_contents).expect("Not a valid TLS certificate"); auth.set_tls_certificate(Some(&cert)); auth.set_tls_authentication_mode(client_auth);