File tree 2 files changed +7
-5
lines changed
2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ pub struct Adapter {
37
37
}
38
38
39
39
// https://github.com/microsoft/windows-rs/blob/master/crates/libs/windows/src/Windows/Devices/Radios/mod.rs
40
- fn get_central_state ( radio : Radio ) -> CentralState {
40
+ fn get_central_state ( radio : & Radio ) -> CentralState {
41
41
let state = radio. State ( ) . unwrap_or ( RadioState :: Unknown ) ;
42
42
match state {
43
43
RadioState :: On => CentralState :: PoweredOn ,
@@ -54,11 +54,13 @@ impl Adapter {
54
54
let radio_clone = radio. clone ( ) ;
55
55
let manager_clone = manager. clone ( ) ;
56
56
let handler = TypedEventHandler :: new ( move |_sender, _args| {
57
- let state = get_central_state ( radio_clone. clone ( ) ) ;
57
+ let state = get_central_state ( & radio_clone) ;
58
58
manager_clone. emit ( CentralEvent :: StateUpdate ( state. into ( ) ) ) ;
59
59
Ok ( ( ) )
60
60
} ) ;
61
- radio. StateChanged ( & handler) ;
61
+ if let Err ( err) = radio. StateChanged ( & handler) {
62
+ eprintln ! ( "radio.StateChanged error: {}" , err) ;
63
+ }
62
64
63
65
Adapter {
64
66
watcher,
@@ -131,6 +133,6 @@ impl Central for Adapter {
131
133
}
132
134
133
135
async fn adapter_state ( & self ) -> Result < CentralState > {
134
- Ok ( get_central_state ( self . radio . clone ( ) ) )
136
+ Ok ( get_central_state ( & self . radio ) )
135
137
}
136
138
}
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ impl api::Manager for Manager {
35
35
Ok ( radios
36
36
. into_iter ( )
37
37
. filter ( |radio| radio. Kind ( ) == Ok ( RadioKind :: Bluetooth ) )
38
- . map ( |radio| Adapter :: new ( radio. clone ( ) ) )
38
+ . map ( |radio| Adapter :: new ( radio) )
39
39
. collect ( ) )
40
40
}
41
41
}
You can’t perform that action at this time.
0 commit comments