Rust fmted
This commit is contained in:
4 files changed
+38
-40
No files matched your search
+6
-6
@@ -1,5 +1,5 @@
|
||||
use super::model::*;
|
||||
use super::xml::{BcPayloads};
|
||||
use super::xml::BcPayloads;
|
||||
use super::xml_crypto;
|
||||
use cookie_factory::bytes::*;
|
||||
use cookie_factory::sequence::tuple;
|
||||
@@ -16,7 +16,6 @@ impl Bc {
|
||||
let body_buf;
|
||||
let payload_offset;
|
||||
|
||||
|
||||
match &self.body {
|
||||
BcBody::ModernMsg(ref modern) => {
|
||||
// First serialize ext
|
||||
@@ -39,11 +38,13 @@ impl Bc {
|
||||
|
||||
// Now get the payload part of the body and add to ext_buf
|
||||
let (temp_buf, _) = gen(
|
||||
opt_ref(&modern.payload, |payload_offset| bc_payload(self.meta.client_idx, payload_offset)),
|
||||
opt_ref(&modern.payload, |payload_offset| {
|
||||
bc_payload(self.meta.client_idx, payload_offset)
|
||||
}),
|
||||
temp_buf,
|
||||
)?;
|
||||
body_buf = temp_buf;
|
||||
},
|
||||
}
|
||||
|
||||
BcBody::LegacyMsg(ref legacy) => {
|
||||
let (buf, _) = gen(bc_legacy(legacy), vec![])?;
|
||||
@@ -57,7 +58,6 @@ impl Bc {
|
||||
|
||||
let (buf, _n) = gen(tuple((bc_header(&header), slice(body_buf))), buf)?;
|
||||
|
||||
|
||||
Ok(buf)
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ fn bc_payload<W: Write>(enc_offset: u32, payload: &BcPayloads) -> impl Serialize
|
||||
BcPayloads::BcXml(x) => {
|
||||
let xml_bytes = x.serialize(vec![]).unwrap();
|
||||
xml_crypto::crypt(enc_offset, &xml_bytes)
|
||||
},
|
||||
}
|
||||
BcPayloads::Binary(x) => x.to_owned(),
|
||||
};
|
||||
slice(payload_bytes)
|
||||
|
||||
+9
-15
@@ -133,11 +133,9 @@ impl BcCamera {
|
||||
|
||||
sub_login.send(legacy_login)?;
|
||||
|
||||
let legacy_reply = sub_login.rx.recv_timeout(RX_TIMEOUT).map_err(|e| {
|
||||
match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => {Error::TimeoutTimeout}
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => {Error::TimeoutDropped}
|
||||
}
|
||||
let legacy_reply = sub_login.rx.recv_timeout(RX_TIMEOUT).map_err(|e| match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => Error::TimeoutTimeout,
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => Error::TimeoutDropped,
|
||||
})?;
|
||||
|
||||
let nonce;
|
||||
@@ -193,11 +191,9 @@ impl BcCamera {
|
||||
);
|
||||
|
||||
sub_login.send(modern_login)?;
|
||||
let modern_reply = sub_login.rx.recv_timeout(RX_TIMEOUT).map_err(|e| {
|
||||
match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => {Error::TimeoutTimeout}
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => {Error::TimeoutDropped}
|
||||
}
|
||||
let modern_reply = sub_login.rx.recv_timeout(RX_TIMEOUT).map_err(|e| match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => Error::TimeoutTimeout,
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => Error::TimeoutDropped,
|
||||
})?;
|
||||
|
||||
let device_info;
|
||||
@@ -255,11 +251,9 @@ impl BcCamera {
|
||||
|
||||
sub_ping.send(ping)?;
|
||||
|
||||
sub_ping.rx.recv_timeout(RX_TIMEOUT).map_err(|e| {
|
||||
match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => {Error::TimeoutTimeout}
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => {Error::TimeoutDropped}
|
||||
}
|
||||
sub_ping.rx.recv_timeout(RX_TIMEOUT).map_err(|e| match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => Error::TimeoutTimeout,
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => Error::TimeoutDropped,
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::Error;
|
||||
use crate::bc::model::*;
|
||||
use crate::bc_protocol::connection::BcSubscription;
|
||||
use super::Error;
|
||||
use log::trace;
|
||||
use log::*;
|
||||
use std::collections::VecDeque;
|
||||
@@ -150,12 +150,14 @@ impl<'a> MediaDataSubscriber<'a> {
|
||||
fn fill_binary_buffer(&mut self, rx_timeout: Duration) -> Result<()> {
|
||||
// Loop messages until we get binary add that data and return
|
||||
loop {
|
||||
let msg = self.bc_sub.rx.recv_timeout(rx_timeout).map_err(|e| {
|
||||
match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => {Error::TimeoutTimeout}
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => {Error::TimeoutDropped}
|
||||
}
|
||||
})?;
|
||||
let msg = self
|
||||
.bc_sub
|
||||
.rx
|
||||
.recv_timeout(rx_timeout)
|
||||
.map_err(|e| match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => Error::TimeoutTimeout,
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => Error::TimeoutDropped,
|
||||
})?;
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
payload: Some(BcPayloads::Binary(binary)),
|
||||
..
|
||||
|
||||
+14
-12
@@ -20,12 +20,13 @@ impl BcCamera {
|
||||
};
|
||||
|
||||
sub_get_general.send(get)?;
|
||||
let msg = sub_get_general.rx.recv_timeout(RX_TIMEOUT).map_err(|e| {
|
||||
match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => {Error::TimeoutTimeout}
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => {Error::TimeoutDropped}
|
||||
}
|
||||
})?;
|
||||
let msg = sub_get_general
|
||||
.rx
|
||||
.recv_timeout(RX_TIMEOUT)
|
||||
.map_err(|e| match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => Error::TimeoutTimeout,
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => Error::TimeoutDropped,
|
||||
})?;
|
||||
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
payload:
|
||||
@@ -111,12 +112,13 @@ impl BcCamera {
|
||||
);
|
||||
|
||||
sub_set_general.send(set)?;
|
||||
let msg = sub_set_general.rx.recv_timeout(RX_TIMEOUT).map_err(|e| {
|
||||
match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => {Error::TimeoutTimeout}
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => {Error::TimeoutDropped}
|
||||
}
|
||||
})?;
|
||||
let msg = sub_set_general
|
||||
.rx
|
||||
.recv_timeout(RX_TIMEOUT)
|
||||
.map_err(|e| match e {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => Error::TimeoutTimeout,
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => Error::TimeoutDropped,
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user