Apply clippy changes
This commit is contained in:
10 files changed
+45
-35
No files matched your search
@@ -245,7 +245,7 @@ fn test_bc_modern_login() {
|
||||
})),
|
||||
..
|
||||
}) => assert_eq!(encryption.nonce, "9E6D1FCB9E69846D"),
|
||||
_ => assert!(false),
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ fn test_bc_legacy_login() {
|
||||
assert_eq!(username, "21232F297A57A5A743894A0E4A801FC\0");
|
||||
assert_eq!(password, EMPTY_LEGACY_PASSWORD);
|
||||
}
|
||||
_ => assert!(false),
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,10 +296,8 @@ fn test_bc_modern_login_failed() {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
extension: None,
|
||||
payload: None,
|
||||
}) => {
|
||||
assert!(true);
|
||||
}
|
||||
_ => assert!(false),
|
||||
}) => {}
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,8 +325,8 @@ fn test_bc_modern_login_success() {
|
||||
BcBody::ModernMsg(ModernMsg {
|
||||
extension: None,
|
||||
payload: Some(_),
|
||||
}) => assert!(true),
|
||||
_ => assert!(false),
|
||||
}) => {}
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +351,7 @@ fn test_bc_binary_mode() {
|
||||
}) => {
|
||||
assert_eq!(bin.len(), 32);
|
||||
}
|
||||
_ => assert!(false),
|
||||
_ => panic!(),
|
||||
}
|
||||
|
||||
context.in_bin_mode.insert(msg1.meta.msg_num);
|
||||
@@ -365,6 +363,6 @@ fn test_bc_binary_mode() {
|
||||
}) => {
|
||||
assert_eq!(bin.len(), 30344);
|
||||
}
|
||||
_ => assert!(false),
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
@@ -209,8 +209,8 @@ fn test_encryption_deser() {
|
||||
|
||||
let t = BcXml::try_parse(sample.as_bytes()).unwrap();
|
||||
match t {
|
||||
top_b if top_b == b => assert!(true),
|
||||
_ => assert!(false),
|
||||
top_b if top_b == b => {},
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,8 +327,8 @@ fn test_deviceinfo_partial_deser() {
|
||||
..
|
||||
}),
|
||||
..
|
||||
} => assert!(true),
|
||||
_ => assert!(false),
|
||||
} => {},
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ fn test_binary_deser() {
|
||||
Extension {
|
||||
binary_data: Some(1),
|
||||
..
|
||||
} => assert!(true),
|
||||
_ => assert!(false),
|
||||
} => {},
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,7 @@ use adpcm::adpcm_to_pcm;
|
||||
use err_derive::Error;
|
||||
use log::*;
|
||||
use std::convert::TryInto;
|
||||
use std::io::Write;
|
||||
use std::net::{SocketAddr, ToSocketAddrs};
|
||||
use std::net::ToSocketAddrs;
|
||||
use std::sync::atomic::{AtomicU16, Ordering};
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -28,13 +27,13 @@ const RX_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum Error {
|
||||
#[error(display = "Communication error")]
|
||||
CommunicationError(#[error(source)] std::io::Error),
|
||||
Communication(#[error(source)] std::io::Error),
|
||||
|
||||
#[error(display = "Deserialization error")]
|
||||
DeserializationError(#[error(source)] bc::de::Error),
|
||||
Deserialization(#[error(source)] bc::de::Error),
|
||||
|
||||
#[error(display = "Serialization error")]
|
||||
SerializationError(#[error(source)] bc::ser::Error),
|
||||
Serialization(#[error(source)] bc::ser::Error),
|
||||
|
||||
#[error(display = "Connection error")]
|
||||
ConnectionError(#[error(source)] self::connection::Error),
|
||||
@@ -74,7 +73,6 @@ impl<'a> From<std::sync::mpsc::RecvTimeoutError> for Error {
|
||||
}
|
||||
|
||||
pub struct BcCamera {
|
||||
address: SocketAddr,
|
||||
channel_id: u8,
|
||||
connection: Option<BcConnection>,
|
||||
logged_in: bool,
|
||||
@@ -114,7 +112,7 @@ impl BcCamera {
|
||||
let conn = match BcConnection::new(addr, RX_TIMEOUT) {
|
||||
Ok(conn) => conn,
|
||||
Err(err) => match err {
|
||||
connection::Error::CommunicationError(ref err) => {
|
||||
connection::Error::Communication(ref err) => {
|
||||
debug!("Assuming timeout from {}", err);
|
||||
continue;
|
||||
}
|
||||
@@ -124,7 +122,6 @@ impl BcCamera {
|
||||
|
||||
debug!("Success: {}", addr);
|
||||
return Ok(Self {
|
||||
address: addr,
|
||||
connection: Some(conn),
|
||||
message_num: AtomicU16::new(0),
|
||||
channel_id,
|
||||
|
||||
@@ -14,6 +14,7 @@ struct AdpcmSetup {
|
||||
|
||||
impl AdpcmSetup {
|
||||
// Unused, originally we thought BC might be using OKI but it is actually DVI4
|
||||
#[allow(dead_code)]
|
||||
fn new_oki() -> Self {
|
||||
Self {
|
||||
max_step_index: 48,
|
||||
@@ -57,10 +58,12 @@ impl Nibble {
|
||||
(self.data & 0b00001111) as u32 // Mask first 4 bits it just to be sure its in nibble range
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn signed_magnitude(&self) -> u32 {
|
||||
(self.data & 0b00000111) as u32 // Mask of first 3 bits which are the magnitiude bits in signed int
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn signed(&self) -> i32 {
|
||||
match self.data & 0b00001000 {
|
||||
// Sign bit is at the 4th bit
|
||||
|
||||
@@ -37,13 +37,13 @@ type Result<T> = std::result::Result<T, Error>;
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
#[error(display = "Communication error")]
|
||||
CommunicationError(#[error(source)] std::io::Error),
|
||||
Communication(#[error(source)] std::io::Error),
|
||||
|
||||
#[error(display = "Deserialization error")]
|
||||
DeserializationError(#[error(source)] bc::de::Error),
|
||||
Deserialization(#[error(source)] bc::de::Error),
|
||||
|
||||
#[error(display = "Serialization error")]
|
||||
SerializationError(#[error(source)] bc::ser::Error),
|
||||
Serialization(#[error(source)] bc::ser::Error),
|
||||
|
||||
#[error(display = "Simultaneous subscription")]
|
||||
SimultaneousSubscription { msg_id: u32 },
|
||||
|
||||
@@ -52,10 +52,14 @@ impl MediaData {
|
||||
MediaData::header_size_from_kind(kind)
|
||||
}
|
||||
|
||||
// Unused was part of debug code
|
||||
#[allow(dead_code)]
|
||||
pub fn header(&self) -> &[u8] {
|
||||
&self.data[0..self.header_size()]
|
||||
}
|
||||
|
||||
// Unused was part of debug code
|
||||
#[allow(dead_code)]
|
||||
pub fn header_dump(&self) {
|
||||
info!("{:?}-hex: {:02?}", self.kind(), self.header());
|
||||
let mut result = vec![];
|
||||
@@ -184,6 +188,8 @@ impl MediaData {
|
||||
}
|
||||
}
|
||||
|
||||
// Unused. TODO: Use this to time stamp video streams correctly
|
||||
#[allow(dead_code)]
|
||||
pub fn timestamp(&self) -> Option<u64> {
|
||||
let kind = self.kind();
|
||||
match kind {
|
||||
|
||||
@@ -46,7 +46,7 @@ impl BcCamera {
|
||||
let datetime =
|
||||
match try_build_timestamp(time_zone, year, month, day, hour, minute, second) {
|
||||
Ok(dt) => dt,
|
||||
Err(e) => {
|
||||
Err(_) => {
|
||||
return Err(Error::UnintelligibleReply {
|
||||
reply: msg,
|
||||
why: "Could not parse date",
|
||||
@@ -110,7 +110,7 @@ impl BcCamera {
|
||||
);
|
||||
|
||||
sub_set_general.send(set)?;
|
||||
let msg = sub_set_general.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
let _ = sub_set_general.rx.recv_timeout(RX_TIMEOUT)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use gstreamer_rtsp_server::{
|
||||
RTSP_TOKEN_MEDIA_FACTORY_ROLE,
|
||||
};
|
||||
use log::*;
|
||||
use neolink_core::bc_protocol::{Error, StreamFormat, StreamOutput, StreamOutputError};
|
||||
use neolink_core::bc_protocol::{StreamFormat, StreamOutput, StreamOutputError};
|
||||
use std::collections::HashSet;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
|
||||
@@ -27,9 +27,9 @@ pub fn main(opt: Opt) -> Result<(), Error> {
|
||||
|
||||
let rtsp = &RtspServer::new();
|
||||
|
||||
set_up_tls(&config, &rtsp);
|
||||
set_up_tls(&config, rtsp);
|
||||
|
||||
set_up_users(&config.users, &rtsp);
|
||||
set_up_users(&config.users, rtsp);
|
||||
|
||||
if config.certificate == None && !config.users.is_empty() {
|
||||
warn!(
|
||||
@@ -132,7 +132,7 @@ fn set_up_tls(config: &Config, rtsp: &RtspServer) {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
if let Some(cert_path) = &config.certificate {
|
||||
rtsp.set_tls(&cert_path, tls_client_auth)
|
||||
rtsp.set_tls(cert_path, tls_client_auth)
|
||||
.expect("Failed to set up TLS");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user