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