@@ -21,7 +21,7 @@ mod serde_path;
2121mod service;
2222
2323pub 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 } ;
2525pub use self :: characteristic:: { CharacteristicFlags , CharacteristicId , CharacteristicInfo } ;
2626pub use self :: descriptor:: { DescriptorId , DescriptorInfo } ;
2727pub use self :: device:: { AddressType , DeviceId , DeviceInfo } ;
@@ -32,17 +32,17 @@ use self::messagestream::MessageStream;
3232pub use self :: modalias:: { Modalias , ParseModaliasError } ;
3333pub use self :: service:: { ServiceId , ServiceInfo } ;
3434use bluez_generated:: {
35+ ORG_BLUEZ_ADAPTER1_NAME , ORG_BLUEZ_DEVICE1_NAME , ORG_BLUEZ_GATT_CHARACTERISTIC1_NAME ,
3536 OrgBluezAdapter1 , OrgBluezAdapter1Properties , OrgBluezDevice1 , OrgBluezDevice1Properties ,
3637 OrgBluezGattCharacteristic1 , OrgBluezGattCharacteristic1Properties , OrgBluezGattDescriptor1 ,
37- OrgBluezGattService1 , ORG_BLUEZ_ADAPTER1_NAME , ORG_BLUEZ_DEVICE1_NAME ,
38- ORG_BLUEZ_GATT_CHARACTERISTIC1_NAME ,
38+ OrgBluezGattService1 ,
3939} ;
40+ use dbus:: Path ;
4041use dbus:: arg:: { PropMap , Variant } ;
4142use dbus:: nonblock:: stdintf:: org_freedesktop_dbus:: { Introspectable , ObjectManager , Properties } ;
4243use dbus:: nonblock:: { Proxy , SyncConnection } ;
43- use dbus:: Path ;
4444use dbus_tokio:: connection:: IOResourceError ;
45- use futures:: stream:: { self , select_all , StreamExt } ;
45+ use futures:: stream:: { self , StreamExt , select_all } ;
4646use futures:: { FutureExt , Stream } ;
4747use std:: collections:: HashMap ;
4848use std:: fmt:: { self , Debug , Display , Formatter } ;
@@ -280,8 +280,8 @@ impl BluetoothSession {
280280 /// Returns a tuple of (join handle, Self).
281281 /// If the join handle ever completes then you're in trouble and should
282282 /// 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 > {
285285 // Connect to the D-Bus system bus (this is blocking, unfortunately).
286286 let ( dbus_resource, connection) = dbus_tokio:: connection:: new_system_sync ( ) ?;
287287 // Configure the connection to send signal messages to all matching `MsgMatch`es, as we may
@@ -621,7 +621,10 @@ impl BluetoothSession {
621621 } )
622622 }
623623
624- fn adapter ( & self , id : & AdapterId ) -> impl OrgBluezAdapter1 + Introspectable + Properties {
624+ fn adapter (
625+ & self ,
626+ id : & AdapterId ,
627+ ) -> impl OrgBluezAdapter1 + Introspectable + Properties + use < > {
625628 Proxy :: new (
626629 "org.bluez" ,
627630 id. object_path . to_owned ( ) ,
@@ -634,7 +637,7 @@ impl BluetoothSession {
634637 & self ,
635638 id : & DeviceId ,
636639 timeout : Duration ,
637- ) -> impl OrgBluezDevice1 + Introspectable + Properties {
640+ ) -> impl OrgBluezDevice1 + Introspectable + Properties + use < > {
638641 let timeout = timeout. min ( DBUS_METHOD_CALL_MAX_TIMEOUT ) ;
639642 Proxy :: new (
640643 "org.bluez" ,
@@ -644,7 +647,10 @@ impl BluetoothSession {
644647 )
645648 }
646649
647- fn service ( & self , id : & ServiceId ) -> impl OrgBluezGattService1 + Introspectable + Properties {
650+ fn service (
651+ & self ,
652+ id : & ServiceId ,
653+ ) -> impl OrgBluezGattService1 + Introspectable + Properties + use < > {
648654 Proxy :: new (
649655 "org.bluez" ,
650656 id. object_path . to_owned ( ) ,
@@ -656,7 +662,7 @@ impl BluetoothSession {
656662 fn characteristic (
657663 & self ,
658664 id : & CharacteristicId ,
659- ) -> impl OrgBluezGattCharacteristic1 + Introspectable + Properties {
665+ ) -> impl OrgBluezGattCharacteristic1 + Introspectable + Properties + use < > {
660666 Proxy :: new (
661667 "org.bluez" ,
662668 id. object_path . to_owned ( ) ,
@@ -668,7 +674,7 @@ impl BluetoothSession {
668674 fn descriptor (
669675 & self ,
670676 id : & DescriptorId ,
671- ) -> impl OrgBluezGattDescriptor1 + Introspectable + Properties {
677+ ) -> impl OrgBluezGattDescriptor1 + Introspectable + Properties + use < > {
672678 Proxy :: new (
673679 "org.bluez" ,
674680 id. object_path . to_owned ( ) ,
@@ -853,7 +859,9 @@ impl BluetoothSession {
853859 }
854860
855861 /// 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 > {
857865 self . filtered_event_stream ( None :: < & DeviceId > , true ) . await
858866 }
859867
@@ -862,7 +870,7 @@ impl BluetoothSession {
862870 pub async fn adapter_event_stream (
863871 & self ,
864872 adapter : & AdapterId ,
865- ) -> Result < impl Stream < Item = BluetoothEvent > , BluetoothError > {
873+ ) -> Result < impl Stream < Item = BluetoothEvent > + use < > , BluetoothError > {
866874 self . filtered_event_stream ( Some ( adapter) , true ) . await
867875 }
868876
@@ -874,24 +882,24 @@ impl BluetoothSession {
874882 pub async fn device_event_stream (
875883 & self ,
876884 device : & DeviceId ,
877- ) -> Result < impl Stream < Item = BluetoothEvent > , BluetoothError > {
885+ ) -> Result < impl Stream < Item = BluetoothEvent > + use < > , BluetoothError > {
878886 self . filtered_event_stream ( Some ( device) , false ) . await
879887 }
880888
881889 /// Get a stream of events for a particular characteristic of a device.
882890 pub async fn characteristic_event_stream (
883891 & self ,
884892 characteristic : & CharacteristicId ,
885- ) -> Result < impl Stream < Item = BluetoothEvent > , BluetoothError > {
893+ ) -> Result < impl Stream < Item = BluetoothEvent > + use < > , BluetoothError > {
886894 self . filtered_event_stream ( Some ( characteristic) , false )
887895 . await
888896 }
889897
890- async fn filtered_event_stream (
898+ async fn filtered_event_stream < P : Into < Path < ' static > > + Clone > (
891899 & self ,
892- object : Option < & ( impl Into < Path < ' static > > + Clone ) > ,
900+ object : Option < & P > ,
893901 device_discovery : bool ,
894- ) -> Result < impl Stream < Item = BluetoothEvent > , BluetoothError > {
902+ ) -> Result < impl Stream < Item = BluetoothEvent > + use < P > , BluetoothError > {
895903 let mut message_streams = vec ! [ ] ;
896904 for match_rule in BluetoothEvent :: match_rules ( object. cloned ( ) , device_discovery) {
897905 let msg_match = self . connection . add_match ( match_rule) . await ?;
0 commit comments