Rust fmt-ed

This commit is contained in:
QuantumEntangledAndy committed 2020-08-03 13:29:33 +07:00
1 parent e973b1eced
commit 832907f574
6 files changed
+24 -22

No files matched your search

+1 -3
View File
@@ -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(),
}
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+9 -5
View File
@@ -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(),
})
}
+11 -10
View File
@@ -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
+1 -2
View File
@@ -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);