Merge branch 'error_updates'
Co-Authored-By: twistedddx <bits@live.com>
This commit is contained in:
2 files changed
+22
-3
No files matched your search
+13
-1
@@ -54,7 +54,10 @@ pub enum Error {
|
||||
DroppedConnection(#[error(source)] std::sync::mpsc::RecvError),
|
||||
|
||||
#[error(display = "Timeout")]
|
||||
Timeout(#[error(source)] std::sync::mpsc::RecvTimeoutError),
|
||||
Timeout,
|
||||
|
||||
#[error(display = "Dropped connection")]
|
||||
TimeoutDisconnected,
|
||||
|
||||
#[error(display = "Credential error")]
|
||||
AuthFailed,
|
||||
@@ -66,6 +69,15 @@ pub enum Error {
|
||||
Other(&'static str),
|
||||
}
|
||||
|
||||
impl<'a> From<std::sync::mpsc::RecvTimeoutError> for Error {
|
||||
fn from(k: std::sync::mpsc::RecvTimeoutError) -> Self {
|
||||
match k {
|
||||
std::sync::mpsc::RecvTimeoutError::Timeout => Error::Timeout,
|
||||
std::sync::mpsc::RecvTimeoutError::Disconnected => Error::TimeoutDisconnected,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for BcCamera {
|
||||
fn drop(&mut self) {
|
||||
self.disconnect();
|
||||
|
||||
@@ -58,8 +58,15 @@ impl BcConnection {
|
||||
let connections_isencrypted = is_encrypted.clone();
|
||||
let rx_thread = std::thread::spawn(move || {
|
||||
let mut context = BcContext::new();
|
||||
context.set_encrypted(connections_isencrypted);
|
||||
while BcConnection::poll(&mut context, &conn, &mut subs).is_ok() {}
|
||||
while {
|
||||
match BcConnection::poll(&mut context, &conn, &mut subs) {
|
||||
Ok(_) => true,
|
||||
Err(err) => {
|
||||
error!("Deserialization error: {:?}", err);
|
||||
false
|
||||
}
|
||||
}
|
||||
} {}
|
||||
});
|
||||
|
||||
Ok(BcConnection {
|
||||
|
||||
Reference in new issue
Block a user