File tree 6 files changed +28
-0
lines changed
6 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -355,6 +355,9 @@ pub trait Central: Send + Sync + Clone {
355
355
/// Add a [`Peripheral`] from a MAC address without a scan result. Not supported on all Bluetooth systems.
356
356
async fn add_peripheral ( & self , address : & PeripheralId ) -> Result < Self :: Peripheral > ;
357
357
358
+ /// Clear the list of [`Peripheral`]s that have been discovered so far.
359
+ async fn clear_peripherals ( & self ) -> Result < ( ) > ;
360
+
358
361
/// Get information about the Bluetooth adapter being used, such as the model or type.
359
362
///
360
363
/// The details of this are platform-specific andyou should not attempt to parse it, but it may
Original file line number Diff line number Diff line change @@ -101,6 +101,12 @@ impl Central for Adapter {
101
101
) )
102
102
}
103
103
104
+ async fn clear_peripherals ( & self ) -> Result < ( ) > {
105
+ Err ( Error :: NotSupported (
106
+ "Can't clear peripheral list on this platform" . to_string ( ) ,
107
+ ) )
108
+ }
109
+
104
110
async fn adapter_info ( & self ) -> Result < String > {
105
111
let adapter_info = self . session . get_adapter_info ( & self . adapter ) . await ?;
106
112
Ok ( format ! ( "{} ({})" , adapter_info. id, adapter_info. modalias) )
Original file line number Diff line number Diff line change 66
66
self . peripherals . insert ( peripheral. id ( ) , peripheral) ;
67
67
}
68
68
69
+ pub fn clear_peripherals ( & self ) {
70
+ self . peripherals . clear ( ) ;
71
+ }
72
+
69
73
pub fn peripherals ( & self ) -> Vec < PeripheralType > {
70
74
self . peripherals
71
75
. iter ( )
Original file line number Diff line number Diff line change @@ -117,6 +117,11 @@ impl Central for Adapter {
117
117
) )
118
118
}
119
119
120
+ async fn clear_peripherals ( & self ) -> Result < ( ) > {
121
+ self . manager . clear_peripherals ( ) ;
122
+ Ok ( ( ) )
123
+ }
124
+
120
125
async fn adapter_info ( & self ) -> Result < String > {
121
126
// TODO: Get information about the adapter.
122
127
Ok ( "CoreBluetooth" . to_string ( ) )
Original file line number Diff line number Diff line change @@ -167,6 +167,11 @@ impl Central for Adapter {
167
167
async fn add_peripheral ( & self , address : & PeripheralId ) -> Result < Peripheral > {
168
168
self . add ( address. 0 )
169
169
}
170
+
171
+ async fn clear_peripherals ( & self ) -> Result < ( ) > {
172
+ self . manager . clear_peripherals ( ) ;
173
+ Ok ( ( ) )
174
+ }
170
175
}
171
176
172
177
pub ( crate ) fn adapter_report_scan_result_internal (
Original file line number Diff line number Diff line change @@ -96,6 +96,11 @@ impl Central for Adapter {
96
96
) )
97
97
}
98
98
99
+ async fn clear_peripherals ( & self ) -> Result < ( ) > {
100
+ self . manager . clear_peripherals ( ) ;
101
+ Ok ( ( ) )
102
+ }
103
+
99
104
async fn adapter_info ( & self ) -> Result < String > {
100
105
// TODO: Get information about the adapter.
101
106
Ok ( "WinRT" . to_string ( ) )
You can’t perform that action at this time.
0 commit comments