Skip to content

Commit 603982d

Browse files
committed
Update to edition 2024.
1 parent 553d6aa commit 603982d

File tree

5 files changed

+32
-24
lines changed

5 files changed

+32
-24
lines changed

bluez-async/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = [
55
"Andrew Walbran <[email protected]>",
66
"David Laban <[email protected]>",
77
]
8-
edition = "2021"
8+
edition = "2024"
99
license = "MIT OR Apache-2.0"
1010
description = "An async wrapper around the D-Bus interface of BlueZ (the Linux Bluetooth daemon), supporting GATT client (central) functionality."
1111
repository = "https://github.com/bluez-rs/bluez-async/"

bluez-async/src/device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bluez_generated::OrgBluezDevice1Properties;
2-
use dbus::arg::{cast, PropMap, RefArg, Variant};
32
use dbus::Path;
3+
use dbus::arg::{PropMap, RefArg, Variant, cast};
44
use serde::{Deserialize, Serialize};
55
use std::collections::HashMap;
66
use std::fmt::{self, Display, Formatter};

bluez-async/src/events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bluez_generated::{
2-
OrgBluezAdapter1Properties, OrgBluezDevice1Properties, OrgBluezGattCharacteristic1Properties,
32
ORG_BLUEZ_ADAPTER1_NAME, ORG_BLUEZ_DEVICE1_NAME, ORG_BLUEZ_GATT_CHARACTERISTIC1_NAME,
3+
OrgBluezAdapter1Properties, OrgBluezDevice1Properties, OrgBluezGattCharacteristic1Properties,
44
};
55
use dbus::message::{MatchRule, SignalArgs};
66
use dbus::nonblock::stdintf::org_freedesktop_dbus::{

bluez-async/src/lib.rs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod serde_path;
2121
mod service;
2222

2323
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};
2525
pub use self::characteristic::{CharacteristicFlags, CharacteristicId, CharacteristicInfo};
2626
pub use self::descriptor::{DescriptorId, DescriptorInfo};
2727
pub use self::device::{AddressType, DeviceId, DeviceInfo};
@@ -32,17 +32,17 @@ use self::messagestream::MessageStream;
3232
pub use self::modalias::{Modalias, ParseModaliasError};
3333
pub use self::service::{ServiceId, ServiceInfo};
3434
use 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;
4041
use dbus::arg::{PropMap, Variant};
4142
use dbus::nonblock::stdintf::org_freedesktop_dbus::{Introspectable, ObjectManager, Properties};
4243
use dbus::nonblock::{Proxy, SyncConnection};
43-
use dbus::Path;
4444
use dbus_tokio::connection::IOResourceError;
45-
use futures::stream::{self, select_all, StreamExt};
45+
use futures::stream::{self, StreamExt, select_all};
4646
use futures::{FutureExt, Stream};
4747
use std::collections::HashMap;
4848
use 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?;

bluez-async/src/messagestream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use dbus::nonblock::{MsgMatch, SyncConnection};
21
use dbus::Message;
3-
use futures::channel::mpsc::UnboundedReceiver;
2+
use dbus::nonblock::{MsgMatch, SyncConnection};
43
use futures::Stream;
4+
use futures::channel::mpsc::UnboundedReceiver;
55
use std::pin::Pin;
66
use std::sync::Arc;
77
use std::task::{Context, Poll};

0 commit comments

Comments
 (0)