@@ -2,12 +2,11 @@ use std::{
2
2
io:: Result ,
3
3
pin:: Pin ,
4
4
task:: { Context , Poll } ,
5
- time:: Duration ,
6
5
} ;
7
6
8
7
use bluer:: l2cap:: { SocketAddr , Stream } ;
9
8
use tokio:: io:: { AsyncRead , AsyncWrite , ReadBuf } ;
10
- use tracing:: { debug , trace} ;
9
+ use tracing:: trace;
11
10
12
11
use crate :: error:: ErrorKind ;
13
12
@@ -19,10 +18,8 @@ pub struct Channel {
19
18
}
20
19
21
20
enum ChannelCreationError {
22
- StreamCreationError ( std:: io:: Error ) ,
23
21
SetSecurityError ( std:: io:: Error ) ,
24
22
ConnectionError ( std:: io:: Error ) ,
25
- ConnectionTimeout ( tokio:: time:: error:: Elapsed ) ,
26
23
}
27
24
28
25
impl Channel {
@@ -80,27 +77,19 @@ impl AsyncWrite for Channel {
80
77
impl From < ChannelCreationError > for crate :: Error {
81
78
fn from ( value : ChannelCreationError ) -> Self {
82
79
let kind = match & value {
83
- ChannelCreationError :: StreamCreationError ( _) | ChannelCreationError :: SetSecurityError ( _) => {
84
- ErrorKind :: Internal
85
- }
80
+ ChannelCreationError :: SetSecurityError ( _) => ErrorKind :: Internal ,
86
81
ChannelCreationError :: ConnectionError ( _) => ErrorKind :: ConnectionFailed ,
87
- ChannelCreationError :: ConnectionTimeout ( _) => ErrorKind :: Timeout ,
88
82
} ;
89
83
let message = match & value {
90
- ChannelCreationError :: StreamCreationError ( _) => "Error creating a new l2cap stream." ,
91
84
ChannelCreationError :: SetSecurityError ( _) => "Error setting connection security level." ,
92
85
ChannelCreationError :: ConnectionError ( _) => "Error connecting to l2cap stream." ,
93
- ChannelCreationError :: ConnectionTimeout ( _) => {
94
- "Timeout occured before stream parameters could be determined."
95
- }
96
86
} ;
97
87
crate :: Error :: new (
98
88
kind,
99
89
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
+ }
104
93
} ,
105
94
message. to_owned ( ) ,
106
95
)
0 commit comments