diff --git a/Cargo.lock b/Cargo.lock index d395699..a08e997 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "bluez-async" -version = "0.8.0" +version = "0.8.1" dependencies = [ "bitflags 2.9.1", "bluez-generated", diff --git a/Cargo.toml b/Cargo.toml index 446dd09..8dfb605 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,3 @@ [workspace] -members = [ - "bluez-async", - "bluez-generated", -] +resolver = "3" +members = ["bluez-async", "bluez-generated"] diff --git a/bluez-async/CHANGELOG.md b/bluez-async/CHANGELOG.md index 070e54b..961a4a3 100644 --- a/bluez-async/CHANGELOG.md +++ b/bluez-async/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## 0.8.1 ### New features diff --git a/bluez-async/Cargo.toml b/bluez-async/Cargo.toml index 27238c0..6e94806 100644 --- a/bluez-async/Cargo.toml +++ b/bluez-async/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "bluez-async" -version = "0.8.0" +version = "0.8.1" authors = [ "Andrew Walbran ", "David Laban ", ] -edition = "2018" +edition = "2024" license = "MIT OR Apache-2.0" description = "An async wrapper around the D-Bus interface of BlueZ (the Linux Bluetooth daemon), supporting GATT client (central) functionality." repository = "https://github.com/bluez-rs/bluez-async/" diff --git a/bluez-async/src/device.rs b/bluez-async/src/device.rs index 1dd241f..27c6ed7 100644 --- a/bluez-async/src/device.rs +++ b/bluez-async/src/device.rs @@ -1,6 +1,6 @@ use bluez_generated::OrgBluezDevice1Properties; -use dbus::arg::{cast, PropMap, RefArg, Variant}; use dbus::Path; +use dbus::arg::{PropMap, RefArg, Variant, cast}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::fmt::{self, Display, Formatter}; diff --git a/bluez-async/src/events.rs b/bluez-async/src/events.rs index 1c02fd6..97c8187 100644 --- a/bluez-async/src/events.rs +++ b/bluez-async/src/events.rs @@ -1,6 +1,6 @@ use bluez_generated::{ - OrgBluezAdapter1Properties, OrgBluezDevice1Properties, OrgBluezGattCharacteristic1Properties, ORG_BLUEZ_ADAPTER1_NAME, ORG_BLUEZ_DEVICE1_NAME, ORG_BLUEZ_GATT_CHARACTERISTIC1_NAME, + OrgBluezAdapter1Properties, OrgBluezDevice1Properties, OrgBluezGattCharacteristic1Properties, }; use dbus::message::{MatchRule, SignalArgs}; use dbus::nonblock::stdintf::org_freedesktop_dbus::{ diff --git a/bluez-async/src/lib.rs b/bluez-async/src/lib.rs index bb551d4..c6509fe 100644 --- a/bluez-async/src/lib.rs +++ b/bluez-async/src/lib.rs @@ -21,7 +21,7 @@ mod serde_path; mod service; pub use self::adapter::{AdapterId, AdapterInfo}; -pub use self::bleuuid::{uuid_from_u16, uuid_from_u32, BleUuid}; +pub use self::bleuuid::{BleUuid, uuid_from_u16, uuid_from_u32}; pub use self::characteristic::{CharacteristicFlags, CharacteristicId, CharacteristicInfo}; pub use self::descriptor::{DescriptorId, DescriptorInfo}; pub use self::device::{AddressType, DeviceId, DeviceInfo}; @@ -32,17 +32,17 @@ use self::messagestream::MessageStream; pub use self::modalias::{Modalias, ParseModaliasError}; pub use self::service::{ServiceId, ServiceInfo}; use bluez_generated::{ + ORG_BLUEZ_ADAPTER1_NAME, ORG_BLUEZ_DEVICE1_NAME, ORG_BLUEZ_GATT_CHARACTERISTIC1_NAME, OrgBluezAdapter1, OrgBluezAdapter1Properties, OrgBluezDevice1, OrgBluezDevice1Properties, OrgBluezGattCharacteristic1, OrgBluezGattCharacteristic1Properties, OrgBluezGattDescriptor1, - OrgBluezGattService1, ORG_BLUEZ_ADAPTER1_NAME, ORG_BLUEZ_DEVICE1_NAME, - ORG_BLUEZ_GATT_CHARACTERISTIC1_NAME, + OrgBluezGattService1, }; +use dbus::Path; use dbus::arg::{PropMap, Variant}; use dbus::nonblock::stdintf::org_freedesktop_dbus::{Introspectable, ObjectManager, Properties}; use dbus::nonblock::{Proxy, SyncConnection}; -use dbus::Path; use dbus_tokio::connection::IOResourceError; -use futures::stream::{self, select_all, StreamExt}; +use futures::stream::{self, StreamExt, select_all}; use futures::{FutureExt, Stream}; use std::collections::HashMap; use std::fmt::{self, Debug, Display, Formatter}; @@ -280,8 +280,8 @@ impl BluetoothSession { /// Returns a tuple of (join handle, Self). /// If the join handle ever completes then you're in trouble and should /// probably restart the process. - pub async fn new( - ) -> Result<(impl Future>, Self), BluetoothError> { + pub async fn new() + -> Result<(impl Future>, Self), BluetoothError> { // Connect to the D-Bus system bus (this is blocking, unfortunately). let (dbus_resource, connection) = dbus_tokio::connection::new_system_sync()?; // Configure the connection to send signal messages to all matching `MsgMatch`es, as we may @@ -621,7 +621,10 @@ impl BluetoothSession { }) } - fn adapter(&self, id: &AdapterId) -> impl OrgBluezAdapter1 + Introspectable + Properties { + fn adapter( + &self, + id: &AdapterId, + ) -> impl OrgBluezAdapter1 + Introspectable + Properties + use<> { Proxy::new( "org.bluez", id.object_path.to_owned(), @@ -634,7 +637,7 @@ impl BluetoothSession { &self, id: &DeviceId, timeout: Duration, - ) -> impl OrgBluezDevice1 + Introspectable + Properties { + ) -> impl OrgBluezDevice1 + Introspectable + Properties + use<> { let timeout = timeout.min(DBUS_METHOD_CALL_MAX_TIMEOUT); Proxy::new( "org.bluez", @@ -644,7 +647,10 @@ impl BluetoothSession { ) } - fn service(&self, id: &ServiceId) -> impl OrgBluezGattService1 + Introspectable + Properties { + fn service( + &self, + id: &ServiceId, + ) -> impl OrgBluezGattService1 + Introspectable + Properties + use<> { Proxy::new( "org.bluez", id.object_path.to_owned(), @@ -656,7 +662,7 @@ impl BluetoothSession { fn characteristic( &self, id: &CharacteristicId, - ) -> impl OrgBluezGattCharacteristic1 + Introspectable + Properties { + ) -> impl OrgBluezGattCharacteristic1 + Introspectable + Properties + use<> { Proxy::new( "org.bluez", id.object_path.to_owned(), @@ -668,7 +674,7 @@ impl BluetoothSession { fn descriptor( &self, id: &DescriptorId, - ) -> impl OrgBluezGattDescriptor1 + Introspectable + Properties { + ) -> impl OrgBluezGattDescriptor1 + Introspectable + Properties + use<> { Proxy::new( "org.bluez", id.object_path.to_owned(), @@ -853,7 +859,9 @@ impl BluetoothSession { } /// Get a stream of events for all devices. - pub async fn event_stream(&self) -> Result, BluetoothError> { + pub async fn event_stream( + &self, + ) -> Result + use<>, BluetoothError> { self.filtered_event_stream(None::<&DeviceId>, true).await } @@ -862,7 +870,7 @@ impl BluetoothSession { pub async fn adapter_event_stream( &self, adapter: &AdapterId, - ) -> Result, BluetoothError> { + ) -> Result + use<>, BluetoothError> { self.filtered_event_stream(Some(adapter), true).await } @@ -874,7 +882,7 @@ impl BluetoothSession { pub async fn device_event_stream( &self, device: &DeviceId, - ) -> Result, BluetoothError> { + ) -> Result + use<>, BluetoothError> { self.filtered_event_stream(Some(device), false).await } @@ -882,16 +890,16 @@ impl BluetoothSession { pub async fn characteristic_event_stream( &self, characteristic: &CharacteristicId, - ) -> Result, BluetoothError> { + ) -> Result + use<>, BluetoothError> { self.filtered_event_stream(Some(characteristic), false) .await } - async fn filtered_event_stream( + async fn filtered_event_stream> + Clone>( &self, - object: Option<&(impl Into> + Clone)>, + object: Option<&P>, device_discovery: bool, - ) -> Result, BluetoothError> { + ) -> Result + use

, BluetoothError> { let mut message_streams = vec![]; for match_rule in BluetoothEvent::match_rules(object.cloned(), device_discovery) { let msg_match = self.connection.add_match(match_rule).await?; diff --git a/bluez-async/src/messagestream.rs b/bluez-async/src/messagestream.rs index e6a797d..351e4be 100644 --- a/bluez-async/src/messagestream.rs +++ b/bluez-async/src/messagestream.rs @@ -1,7 +1,7 @@ -use dbus::nonblock::{MsgMatch, SyncConnection}; use dbus::Message; -use futures::channel::mpsc::UnboundedReceiver; +use dbus::nonblock::{MsgMatch, SyncConnection}; use futures::Stream; +use futures::channel::mpsc::UnboundedReceiver; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll};