Skip to content

Commit cf6ff29

Browse files
committed
clippy
1 parent 5c60d1a commit cf6ff29

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/bluer/l2cap_channel.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ use std::{
22
io::Result,
33
pin::Pin,
44
task::{Context, Poll},
5-
time::Duration,
65
};
76

87
use bluer::l2cap::{SocketAddr, Stream};
98
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
10-
use tracing::{debug, trace};
9+
use tracing::trace;
1110

1211
use crate::error::ErrorKind;
1312

@@ -19,10 +18,8 @@ pub struct Channel {
1918
}
2019

2120
enum ChannelCreationError {
22-
StreamCreationError(std::io::Error),
2321
SetSecurityError(std::io::Error),
2422
ConnectionError(std::io::Error),
25-
ConnectionTimeout(tokio::time::error::Elapsed),
2623
}
2724

2825
impl Channel {
@@ -80,27 +77,19 @@ impl AsyncWrite for Channel {
8077
impl From<ChannelCreationError> for crate::Error {
8178
fn from(value: ChannelCreationError) -> Self {
8279
let kind = match &value {
83-
ChannelCreationError::StreamCreationError(_) | ChannelCreationError::SetSecurityError(_) => {
84-
ErrorKind::Internal
85-
}
80+
ChannelCreationError::SetSecurityError(_) => ErrorKind::Internal,
8681
ChannelCreationError::ConnectionError(_) => ErrorKind::ConnectionFailed,
87-
ChannelCreationError::ConnectionTimeout(_) => ErrorKind::Timeout,
8882
};
8983
let message = match &value {
90-
ChannelCreationError::StreamCreationError(_) => "Error creating a new l2cap stream.",
9184
ChannelCreationError::SetSecurityError(_) => "Error setting connection security level.",
9285
ChannelCreationError::ConnectionError(_) => "Error connecting to l2cap stream.",
93-
ChannelCreationError::ConnectionTimeout(_) => {
94-
"Timeout occured before stream parameters could be determined."
95-
}
9686
};
9787
crate::Error::new(
9888
kind,
9989
match value {
100-
ChannelCreationError::StreamCreationError(io)
101-
| ChannelCreationError::SetSecurityError(io)
102-
| ChannelCreationError::ConnectionError(io) => Some(Box::new(io)),
103-
ChannelCreationError::ConnectionTimeout(elapsed) => Some(Box::new(elapsed)),
90+
ChannelCreationError::SetSecurityError(io) | ChannelCreationError::ConnectionError(io) => {
91+
Some(Box::new(io))
92+
}
10493
},
10594
message.to_owned(),
10695
)

src/corebluetooth/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ pub(super) unsafe trait NSStream: Sized + Message {
621621
}
622622
}
623623

624+
/// # Safety
625+
/// Only implement for objective C object that inherit from CFStream (https://developer.apple.com/documentation/corefoundation/cfstream)
624626
pub(super) unsafe trait CFStream: Sized + Message {
625627
fn property(&self, key: &id) -> Option<&NSData> {
626628
let key = unsafe { extern_nsstring(*key) };

0 commit comments

Comments
 (0)