@@ -21,7 +21,7 @@ mod serde_path;
21
21
mod service;
22
22
23
23
pub use self :: adapter:: { AdapterId , AdapterInfo } ;
24
- pub use self :: bleuuid:: { uuid_from_u16 , uuid_from_u32 , BleUuid } ;
24
+ pub use self :: bleuuid:: { BleUuid , uuid_from_u16 , uuid_from_u32 } ;
25
25
pub use self :: characteristic:: { CharacteristicFlags , CharacteristicId , CharacteristicInfo } ;
26
26
pub use self :: descriptor:: { DescriptorId , DescriptorInfo } ;
27
27
pub use self :: device:: { AddressType , DeviceId , DeviceInfo } ;
@@ -32,17 +32,17 @@ use self::messagestream::MessageStream;
32
32
pub use self :: modalias:: { Modalias , ParseModaliasError } ;
33
33
pub use self :: service:: { ServiceId , ServiceInfo } ;
34
34
use bluez_generated:: {
35
+ ORG_BLUEZ_ADAPTER1_NAME , ORG_BLUEZ_DEVICE1_NAME , ORG_BLUEZ_GATT_CHARACTERISTIC1_NAME ,
35
36
OrgBluezAdapter1 , OrgBluezAdapter1Properties , OrgBluezDevice1 , OrgBluezDevice1Properties ,
36
37
OrgBluezGattCharacteristic1 , OrgBluezGattCharacteristic1Properties , OrgBluezGattDescriptor1 ,
37
- OrgBluezGattService1 , ORG_BLUEZ_ADAPTER1_NAME , ORG_BLUEZ_DEVICE1_NAME ,
38
- ORG_BLUEZ_GATT_CHARACTERISTIC1_NAME ,
38
+ OrgBluezGattService1 ,
39
39
} ;
40
+ use dbus:: Path ;
40
41
use dbus:: arg:: { PropMap , Variant } ;
41
42
use dbus:: nonblock:: stdintf:: org_freedesktop_dbus:: { Introspectable , ObjectManager , Properties } ;
42
43
use dbus:: nonblock:: { Proxy , SyncConnection } ;
43
- use dbus:: Path ;
44
44
use dbus_tokio:: connection:: IOResourceError ;
45
- use futures:: stream:: { self , select_all , StreamExt } ;
45
+ use futures:: stream:: { self , StreamExt , select_all } ;
46
46
use futures:: { FutureExt , Stream } ;
47
47
use std:: collections:: HashMap ;
48
48
use std:: fmt:: { self , Debug , Display , Formatter } ;
@@ -280,8 +280,8 @@ impl BluetoothSession {
280
280
/// Returns a tuple of (join handle, Self).
281
281
/// If the join handle ever completes then you're in trouble and should
282
282
/// probably restart the process.
283
- pub async fn new (
284
- ) -> Result < ( impl Future < Output = Result < ( ) , SpawnError > > , Self ) , BluetoothError > {
283
+ pub async fn new ( )
284
+ -> Result < ( impl Future < Output = Result < ( ) , SpawnError > > , Self ) , BluetoothError > {
285
285
// Connect to the D-Bus system bus (this is blocking, unfortunately).
286
286
let ( dbus_resource, connection) = dbus_tokio:: connection:: new_system_sync ( ) ?;
287
287
// Configure the connection to send signal messages to all matching `MsgMatch`es, as we may
@@ -621,7 +621,10 @@ impl BluetoothSession {
621
621
} )
622
622
}
623
623
624
- fn adapter ( & self , id : & AdapterId ) -> impl OrgBluezAdapter1 + Introspectable + Properties {
624
+ fn adapter (
625
+ & self ,
626
+ id : & AdapterId ,
627
+ ) -> impl OrgBluezAdapter1 + Introspectable + Properties + use < > {
625
628
Proxy :: new (
626
629
"org.bluez" ,
627
630
id. object_path . to_owned ( ) ,
@@ -634,7 +637,7 @@ impl BluetoothSession {
634
637
& self ,
635
638
id : & DeviceId ,
636
639
timeout : Duration ,
637
- ) -> impl OrgBluezDevice1 + Introspectable + Properties {
640
+ ) -> impl OrgBluezDevice1 + Introspectable + Properties + use < > {
638
641
let timeout = timeout. min ( DBUS_METHOD_CALL_MAX_TIMEOUT ) ;
639
642
Proxy :: new (
640
643
"org.bluez" ,
@@ -644,7 +647,10 @@ impl BluetoothSession {
644
647
)
645
648
}
646
649
647
- fn service ( & self , id : & ServiceId ) -> impl OrgBluezGattService1 + Introspectable + Properties {
650
+ fn service (
651
+ & self ,
652
+ id : & ServiceId ,
653
+ ) -> impl OrgBluezGattService1 + Introspectable + Properties + use < > {
648
654
Proxy :: new (
649
655
"org.bluez" ,
650
656
id. object_path . to_owned ( ) ,
@@ -656,7 +662,7 @@ impl BluetoothSession {
656
662
fn characteristic (
657
663
& self ,
658
664
id : & CharacteristicId ,
659
- ) -> impl OrgBluezGattCharacteristic1 + Introspectable + Properties {
665
+ ) -> impl OrgBluezGattCharacteristic1 + Introspectable + Properties + use < > {
660
666
Proxy :: new (
661
667
"org.bluez" ,
662
668
id. object_path . to_owned ( ) ,
@@ -668,7 +674,7 @@ impl BluetoothSession {
668
674
fn descriptor (
669
675
& self ,
670
676
id : & DescriptorId ,
671
- ) -> impl OrgBluezGattDescriptor1 + Introspectable + Properties {
677
+ ) -> impl OrgBluezGattDescriptor1 + Introspectable + Properties + use < > {
672
678
Proxy :: new (
673
679
"org.bluez" ,
674
680
id. object_path . to_owned ( ) ,
@@ -853,7 +859,9 @@ impl BluetoothSession {
853
859
}
854
860
855
861
/// Get a stream of events for all devices.
856
- pub async fn event_stream ( & self ) -> Result < impl Stream < Item = BluetoothEvent > , BluetoothError > {
862
+ pub async fn event_stream (
863
+ & self ,
864
+ ) -> Result < impl Stream < Item = BluetoothEvent > + use < > , BluetoothError > {
857
865
self . filtered_event_stream ( None :: < & DeviceId > , true ) . await
858
866
}
859
867
@@ -862,7 +870,7 @@ impl BluetoothSession {
862
870
pub async fn adapter_event_stream (
863
871
& self ,
864
872
adapter : & AdapterId ,
865
- ) -> Result < impl Stream < Item = BluetoothEvent > , BluetoothError > {
873
+ ) -> Result < impl Stream < Item = BluetoothEvent > + use < > , BluetoothError > {
866
874
self . filtered_event_stream ( Some ( adapter) , true ) . await
867
875
}
868
876
@@ -874,24 +882,24 @@ impl BluetoothSession {
874
882
pub async fn device_event_stream (
875
883
& self ,
876
884
device : & DeviceId ,
877
- ) -> Result < impl Stream < Item = BluetoothEvent > , BluetoothError > {
885
+ ) -> Result < impl Stream < Item = BluetoothEvent > + use < > , BluetoothError > {
878
886
self . filtered_event_stream ( Some ( device) , false ) . await
879
887
}
880
888
881
889
/// Get a stream of events for a particular characteristic of a device.
882
890
pub async fn characteristic_event_stream (
883
891
& self ,
884
892
characteristic : & CharacteristicId ,
885
- ) -> Result < impl Stream < Item = BluetoothEvent > , BluetoothError > {
893
+ ) -> Result < impl Stream < Item = BluetoothEvent > + use < > , BluetoothError > {
886
894
self . filtered_event_stream ( Some ( characteristic) , false )
887
895
. await
888
896
}
889
897
890
- async fn filtered_event_stream (
898
+ async fn filtered_event_stream < P : Into < Path < ' static > > + Clone > (
891
899
& self ,
892
- object : Option < & ( impl Into < Path < ' static > > + Clone ) > ,
900
+ object : Option < & P > ,
893
901
device_discovery : bool ,
894
- ) -> Result < impl Stream < Item = BluetoothEvent > , BluetoothError > {
902
+ ) -> Result < impl Stream < Item = BluetoothEvent > + use < P > , BluetoothError > {
895
903
let mut message_streams = vec ! [ ] ;
896
904
for match_rule in BluetoothEvent :: match_rules ( object. cloned ( ) , device_discovery) {
897
905
let msg_match = self . connection . add_match ( match_rule) . await ?;
0 commit comments