From da2ed7a16dc094ece314a27ec46a67edb942eba2 Mon Sep 17 00:00:00 2001 From: Zeeshan Ali Khan Date: Tue, 8 Oct 2024 13:31:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20Port=20to=20latest=20zb?= =?UTF-8?q?us=20main=20(upcoming=205.0=20release)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on a patch from Marc-André Lureau (@elmarco). --- Cargo.lock | 99 +++++------------------------------------ Cargo.toml | 4 +- src/bus/mod.rs | 8 ++-- src/fdo/dbus.rs | 30 ++++++------- src/fdo/mod.rs | 4 +- src/fdo/monitoring.rs | 8 ++-- src/peer/mod.rs | 6 +-- src/peer/stream.rs | 12 +++-- src/peers.rs | 5 ++- tests/fdo.rs | 7 +-- tests/greet.rs | 19 ++++---- tests/monitor.rs | 15 ++++--- tests/multiple_conns.rs | 4 +- 13 files changed, 75 insertions(+), 146 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b6d5b0..d6bc72c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -324,15 +324,6 @@ version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - [[package]] name = "blocking" version = "1.5.1" @@ -498,15 +489,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "cpufeatures" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" -dependencies = [ - "libc", -] - [[package]] name = "crc32fast" version = "1.3.2" @@ -531,26 +513,6 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", -] - [[package]] name = "either" version = "1.10.0" @@ -742,16 +704,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "getrandom" version = "0.2.12" @@ -1440,17 +1392,6 @@ dependencies = [ "syn 2.0.65", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sharded-slab" version = "0.1.7" @@ -1749,12 +1690,6 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - [[package]] name = "uds_windows" version = "1.1.0" @@ -1784,12 +1719,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - [[package]] name = "want" version = "0.3.1" @@ -1997,8 +1926,7 @@ dependencies = [ [[package]] name = "zbus" version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725" +source = "git+https://github.com/dbus2/zbus/#d85ef960cb43c120c356406b2639b98140bb4906" dependencies = [ "async-broadcast", "async-process", @@ -2007,7 +1935,6 @@ dependencies = [ "enumflags2", "event-listener 5.3.1", "futures-core", - "futures-sink", "futures-util", "hex", "nix", @@ -2015,12 +1942,11 @@ dependencies = [ "rand", "serde", "serde_repr", - "sha1", "static_assertions", "tokio", "tracing", "uds_windows", - "windows-sys 0.52.0", + "windows-sys 0.59.0", "xdg-home", "zbus_macros", "zbus_names", @@ -2030,8 +1956,7 @@ dependencies = [ [[package]] name = "zbus_macros" version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e" +source = "git+https://github.com/dbus2/zbus/#d85ef960cb43c120c356406b2639b98140bb4906" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2043,8 +1968,7 @@ dependencies = [ [[package]] name = "zbus_names" version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c" +source = "git+https://github.com/dbus2/zbus/#d85ef960cb43c120c356406b2639b98140bb4906" dependencies = [ "serde", "static_assertions", @@ -2054,21 +1978,20 @@ dependencies = [ [[package]] name = "zvariant" version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe" +source = "git+https://github.com/dbus2/zbus/#d85ef960cb43c120c356406b2639b98140bb4906" dependencies = [ "endi", "enumflags2", "serde", "static_assertions", "zvariant_derive", + "zvariant_utils", ] [[package]] name = "zvariant_derive" version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449" +source = "git+https://github.com/dbus2/zbus/#d85ef960cb43c120c356406b2639b98140bb4906" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2079,11 +2002,13 @@ dependencies = [ [[package]] name = "zvariant_utils" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" +version = "2.2.0" +source = "git+https://github.com/dbus2/zbus/#d85ef960cb43c120c356406b2639b98140bb4906" dependencies = [ + "nom", "proc-macro2", "quote", + "serde", + "static_assertions", "syn 2.0.65", ] diff --git a/Cargo.toml b/Cargo.toml index 05e128b..536bdf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,8 +20,8 @@ name = "busd" path = "src/bin/busd.rs" [dependencies] -#zbus = { git = "https://github.com/dbus2/zbus/", features = [ -zbus = { version = "4.2.0", features = [ +zbus = { git = "https://github.com/dbus2/zbus/", features = [ +#zbus = { version = "4.2.0", features = [ "tokio", "bus-impl", ], default-features = false } diff --git a/src/bus/mod.rs b/src/bus/mod.rs index 4eb0a05..1ca1c80 100644 --- a/src/bus/mod.rs +++ b/src/bus/mod.rs @@ -10,8 +10,8 @@ use tracing::{debug, info, trace, warn}; use zbus::address::transport::{Unix, UnixSocket}; use zbus::{ address::{transport::Tcp, Transport}, - connection::socket::BoxedSplit, - Address, AuthMechanism, Connection, ConnectionBuilder, Guid, OwnedGuid, + connection::{self, socket::BoxedSplit}, + Address, AuthMechanism, Connection, Guid, OwnedGuid, }; use crate::{ @@ -83,7 +83,7 @@ impl Bus { // Create a peer for ourselves. trace!("Creating self-dial connection."); let (client_socket, peer_socket) = zbus::connection::socket::Channel::pair(); - let service_conn = ConnectionBuilder::authenticated_socket(client_socket, guid.clone())? + let service_conn = connection::Builder::authenticated_socket(client_socket, guid.clone())? .p2p() .unique_name(fdo::BUS_NAME)? .name(fdo::BUS_NAME)? @@ -91,7 +91,7 @@ impl Bus { .serve_at(fdo::Monitoring::PATH, monitoring)? .build() .await?; - let peer_conn = ConnectionBuilder::authenticated_socket(peer_socket, guid.clone())? + let peer_conn = connection::Builder::authenticated_socket(peer_socket, guid.clone())? .p2p() .build() .await?; diff --git a/src/fdo/dbus.rs b/src/fdo/dbus.rs index 0c288e2..d652394 100644 --- a/src/fdo/dbus.rs +++ b/src/fdo/dbus.rs @@ -10,10 +10,11 @@ use zbus::{ fdo::{ ConnectionCredentials, Error, ReleaseNameReply, RequestNameFlags, RequestNameReply, Result, }, - interface, + interface, message, names::{BusName, InterfaceName, OwnedBusName, OwnedUniqueName, UniqueName, WellKnownName}, + object_server::{ResponseDispatchNotifier, SignalEmitter}, zvariant::Optional, - MessageHeader, OwnedGuid, OwnedMatchRule, ResponseDispatchNotifier, SignalContext, + OwnedGuid, OwnedMatchRule, }; use super::msg_sender; @@ -37,7 +38,7 @@ impl DBus { } /// Helper for D-Bus methods that call a function on a peer. - async fn call_mut_on_peer(&self, func: F, hdr: MessageHeader<'_>) -> Result + async fn call_mut_on_peer(&self, func: F, hdr: message::Header<'_>) -> Result where F: FnOnce(&mut Peer) -> Result, { @@ -64,8 +65,8 @@ impl DBus { /// This is already called & handled and we only need to handle it once. async fn hello( &self, - #[zbus(header)] hdr: MessageHeader<'_>, - #[zbus(signal_context)] ctxt: SignalContext<'_>, + #[zbus(header)] hdr: message::Header<'_>, + #[zbus(signal_emitter)] emitter: SignalEmitter<'_>, ) -> Result> { let name = msg_sender(&hdr); let peers = self.peers()?; @@ -80,7 +81,7 @@ impl DBus { // 2. The `Hello` response to arrive before the `NameAcquired` signal. let unique_name = peer.unique_name().clone(); let (response, listener) = ResponseDispatchNotifier::new(unique_name.clone()); - let ctxt = ctxt.to_owned(); + let ctxt = emitter.to_owned(); spawn(async move { listener.await; let owner = UniqueName::from(unique_name); @@ -110,7 +111,7 @@ impl DBus { &self, name: WellKnownName<'_>, flags: BitFlags, - #[zbus(header)] hdr: MessageHeader<'_>, + #[zbus(header)] hdr: message::Header<'_>, ) -> Result { let unique_name = msg_sender(&hdr); let peers = self.peers()?; @@ -133,7 +134,7 @@ impl DBus { async fn release_name( &self, name: WellKnownName<'_>, - #[zbus(header)] hdr: MessageHeader<'_>, + #[zbus(header)] hdr: message::Header<'_>, ) -> Result { let unique_name = msg_sender(&hdr); let peers = self.peers()?; @@ -175,7 +176,7 @@ impl DBus { async fn add_match( &self, rule: OwnedMatchRule, - #[zbus(header)] hdr: MessageHeader<'_>, + #[zbus(header)] hdr: message::Header<'_>, ) -> Result<()> { self.call_mut_on_peer( move |peer| { @@ -192,7 +193,7 @@ impl DBus { async fn remove_match( &self, rule: OwnedMatchRule, - #[zbus(header)] hdr: MessageHeader<'_>, + #[zbus(header)] hdr: message::Header<'_>, ) -> Result<()> { self.call_mut_on_peer(move |peer| peer.remove_match_rule(rule), hdr) .await @@ -384,7 +385,7 @@ impl DBus { /// It's also the signal to use to detect the appearance of new names on the bus. #[zbus(signal)] pub async fn name_owner_changed( - signal_ctxt: &SignalContext<'_>, + emitter: &SignalEmitter<'_>, name: BusName<'_>, old_owner: Optional>, new_owner: Optional>, @@ -392,12 +393,9 @@ impl DBus { /// This signal is sent to a specific application when it loses ownership of a name. #[zbus(signal)] - pub async fn name_lost(signal_ctxt: &SignalContext<'_>, name: BusName<'_>) -> zbus::Result<()>; + pub async fn name_lost(emitter: &SignalEmitter<'_>, name: BusName<'_>) -> zbus::Result<()>; /// This signal is sent to a specific application when it gains ownership of a name. #[zbus(signal)] - pub async fn name_acquired( - signal_ctxt: &SignalContext<'_>, - name: BusName<'_>, - ) -> zbus::Result<()>; + pub async fn name_acquired(emitter: &SignalEmitter<'_>, name: BusName<'_>) -> zbus::Result<()>; } diff --git a/src/fdo/mod.rs b/src/fdo/mod.rs index 446cae7..0e87199 100644 --- a/src/fdo/mod.rs +++ b/src/fdo/mod.rs @@ -2,12 +2,12 @@ mod dbus; pub use dbus::*; mod monitoring; pub use monitoring::*; -use zbus::{names::UniqueName, MessageHeader}; +use zbus::{message, names::UniqueName}; pub const BUS_NAME: &str = "org.freedesktop.DBus"; /// Helper for getting the peer name from a message header. -fn msg_sender<'h>(hdr: &'h MessageHeader<'h>) -> &'h UniqueName<'h> { +fn msg_sender<'h>(hdr: &'h message::Header<'h>) -> &'h UniqueName<'h> { // SAFETY: The bus (that's us!) is supposed to ensure a valid sender on the message. hdr.sender().expect("Missing `sender` header") } diff --git a/src/fdo/monitoring.rs b/src/fdo/monitoring.rs index d9cfad0..19c3d16 100644 --- a/src/fdo/monitoring.rs +++ b/src/fdo/monitoring.rs @@ -4,9 +4,9 @@ use tokio::spawn; use tracing::{debug, warn}; use zbus::{ fdo::{Error, Result}, - interface, + interface, message, + object_server::{ResponseDispatchNotifier, SignalEmitter}, zvariant::Optional, - MessageHeader, ResponseDispatchNotifier, SignalContext, }; use super::msg_sender; @@ -34,8 +34,8 @@ impl Monitoring { &self, match_rules: MatchRules, _flags: u32, - #[zbus(header)] hdr: MessageHeader<'_>, - #[zbus(signal_context)] ctxt: SignalContext<'_>, + #[zbus(header)] hdr: message::Header<'_>, + #[zbus(signal_emitter)] ctxt: SignalEmitter<'_>, ) -> Result> { let owner = msg_sender(&hdr).to_owned(); let peers = self diff --git a/src/peer/mod.rs b/src/peer/mod.rs index ffc3ec3..5e31aa1 100644 --- a/src/peer/mod.rs +++ b/src/peer/mod.rs @@ -7,8 +7,8 @@ pub use monitor::*; use anyhow::Result; use tracing::trace; use zbus::{ - connection::socket::BoxedSplit, names::OwnedUniqueName, AuthMechanism, Connection, - ConnectionBuilder, OwnedGuid, OwnedMatchRule, + connection, connection::socket::BoxedSplit, names::OwnedUniqueName, AuthMechanism, Connection, + OwnedGuid, OwnedMatchRule, }; use crate::{fdo, match_rules::MatchRules, name_registry::NameRegistry}; @@ -31,7 +31,7 @@ impl Peer { auth_mechanism: AuthMechanism, ) -> Result { let unique_name = OwnedUniqueName::try_from(format!(":busd.{id}")).unwrap(); - let conn = ConnectionBuilder::socket(socket) + let conn = connection::Builder::socket(socket) .server(guid)? .p2p() .auth_mechanism(auth_mechanism) diff --git a/src/peer/stream.rs b/src/peer/stream.rs index 926ff27..9a6db8a 100644 --- a/src/peer/stream.rs +++ b/src/peer/stream.rs @@ -3,7 +3,7 @@ use std::pin::Pin; use anyhow::{bail, Error, Result}; use futures_util::{Stream as FutureStream, TryStream, TryStreamExt}; use tracing::trace; -use zbus::{zvariant::Type, Message, MessageBuilder, MessageStream, MessageType}; +use zbus::{message, Message, MessageStream}; use crate::peer::Peer; @@ -30,7 +30,8 @@ impl Stream { let header = msg.header(); // Ensure destination field is present and readable for non-signals. - if msg.message_type() != MessageType::Signal && header.destination().is_none() { + if msg.message_type() != message::Type::Signal && header.destination().is_none() + { bail!("missing destination field"); } @@ -40,10 +41,7 @@ impl Stream { Some(sender) if *sender == unique_name => Ok(msg), Some(_) => bail!("failed to parse message: Invalid sender field"), None => { - let signature = match header.signature() { - Some(sig) => sig.clone(), - None => <()>::signature(), - }; + let signature = header.signature(); let body = msg.body(); let body_bytes = body.data(); #[cfg(unix)] @@ -53,7 +51,7 @@ impl Stream { .map(|fd| fd.try_clone().map(Into::into)) .collect::>>()?; let builder = - MessageBuilder::from(header.clone()).sender(&unique_name)?; + message::Builder::from(header.clone()).sender(&unique_name)?; let new_msg = unsafe { builder.build_raw_body( body_bytes, diff --git a/src/peers.rs b/src/peers.rs index de3d320..ed4af36 100644 --- a/src/peers.rs +++ b/src/peers.rs @@ -13,9 +13,10 @@ use tokio::{spawn, sync::RwLock}; use tracing::{debug, trace, warn}; use zbus::{ connection::socket::BoxedSplit, + message, names::{BusName, OwnedUniqueName, UniqueName}, zvariant::Optional, - AuthMechanism, Message, MessageType, OwnedGuid, + AuthMechanism, Message, OwnedGuid, }; use crate::{ @@ -217,7 +218,7 @@ impl Peers { }; match msg.message_type() { - MessageType::Signal => self.broadcast_msg(msg).await, + message::Type::Signal => self.broadcast_msg(msg).await, _ => match msg.header().destination() { Some(dest) => { if let Err(e) = self.send_msg(msg.clone(), dest.clone()).await { diff --git a/tests/fdo.rs b/tests/fdo.rs index 6a98f5d..332b44c 100644 --- a/tests/fdo.rs +++ b/tests/fdo.rs @@ -13,9 +13,10 @@ use rand::{ use tokio::{select, sync::oneshot::Sender}; use tracing::instrument; use zbus::{ + connection, fdo::{self, DBusProxy, ReleaseNameReply, RequestNameFlags, RequestNameReply}, names::{BusName, WellKnownName}, - CacheProperties, ConnectionBuilder, + proxy::CacheProperties, }; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] @@ -62,7 +63,7 @@ async fn name_ownership_changes_(address: &str) { #[instrument] async fn name_ownership_changes_client(address: &str, tx: Sender<()>) -> anyhow::Result<()> { - let conn = ConnectionBuilder::address(address)?.build().await?; + let conn = connection::Builder::address(address)?.build().await?; let conn_unique_name = conn.unique_name().unwrap().to_owned(); let dbus_proxy = DBusProxy::builder(&conn) .cache_properties(CacheProperties::No) @@ -124,7 +125,7 @@ async fn name_ownership_changes_client(address: &str, tx: Sender<()>) -> anyhow: ); // Now we try with another connection and we should be queued. - let conn2 = ConnectionBuilder::address(address)?.build().await?; + let conn2 = connection::Builder::address(address)?.build().await?; let conn2_unique_name = conn2.unique_name().unwrap().to_owned(); let changed = name_changed_stream.next().await.unwrap(); ensure!( diff --git a/tests/greet.rs b/tests/greet.rs index 6fec8df..777ecc2 100644 --- a/tests/greet.rs +++ b/tests/greet.rs @@ -14,11 +14,14 @@ use rand::{ use tokio::{select, sync::mpsc::channel, time::timeout}; use tracing::instrument; use zbus::{ + connection, fdo::{self, DBusProxy}, - interface, proxy, + interface, message, + object_server::SignalEmitter, + proxy, + proxy::CacheProperties, zvariant::ObjectPath, - AsyncDrop, CacheProperties, Connection, ConnectionBuilder, MatchRule, MessageHeader, - MessageStream, SignalContext, + AsyncDrop, Connection, MatchRule, MessageStream, }; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] @@ -78,8 +81,8 @@ async fn greet_service(socket_addr: &str) -> anyhow::Result { async fn say_hello( &mut self, name: &str, - #[zbus(signal_context)] ctxt: SignalContext<'_>, - #[zbus(header)] header: MessageHeader<'_>, + #[zbus(signal_emitter)] ctxt: SignalEmitter<'_>, + #[zbus(header)] header: message::Header<'_>, ) -> fdo::Result { self.count += 1; let path = header.path().unwrap().clone(); @@ -92,7 +95,7 @@ async fn greet_service(socket_addr: &str) -> anyhow::Result { #[zbus(signal)] async fn greeted( - ctxt: &SignalContext<'_>, + ctxt: &SignalEmitter<'_>, name: &str, count: u64, path: ObjectPath<'_>, @@ -100,7 +103,7 @@ async fn greet_service(socket_addr: &str) -> anyhow::Result { } let greeter = Greeter { count: 0 }; - ConnectionBuilder::address(socket_addr)? + connection::Builder::address(socket_addr)? .name("org.zbus.MyGreeter")? .serve_at("/org/zbus/MyGreeter", greeter)? .build() @@ -121,7 +124,7 @@ async fn greet_client(socket_addr: &str) -> anyhow::Result<()> { async fn greeted(name: &str, count: u64, path: ObjectPath<'_>); } - let conn = ConnectionBuilder::address(socket_addr)?.build().await?; + let conn = connection::Builder::address(socket_addr)?.build().await?; let proxy = MyGreeterProxy::builder(&conn) .destination("org.zbus.MyGreeter")? diff --git a/tests/monitor.rs b/tests/monitor.rs index 49d5790..5169a9c 100644 --- a/tests/monitor.rs +++ b/tests/monitor.rs @@ -5,9 +5,12 @@ use ntest::timeout; use tokio::{select, sync::oneshot::Sender}; use tracing::instrument; use zbus::{ + connection, fdo::{DBusProxy, MonitoringProxy, NameAcquired, NameLost, NameOwnerChanged, RequestNameFlags}, + message, names::BusName, - CacheProperties, ConnectionBuilder, MessageStream, MessageType, + proxy::CacheProperties, + MessageStream, }; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] @@ -41,7 +44,7 @@ async fn become_monitor() { #[instrument] async fn become_monitor_client(address: &str, tx: Sender<()>) -> anyhow::Result<()> { // Create a monitor that wants all messages. - let conn = ConnectionBuilder::address(address)?.build().await?; + let conn = connection::Builder::address(address)?.build().await?; let mut msg_stream = MessageStream::from(&conn); MonitoringProxy::builder(&conn) .cache_properties(CacheProperties::No) @@ -78,7 +81,7 @@ async fn become_monitor_client(address: &str, tx: Sender<()>) -> anyhow::Result< ); // Now a client that calls a method that triggers a signal. - let conn = ConnectionBuilder::address(address)?.build().await?; + let conn = connection::Builder::address(address)?.build().await?; let name = "org.dbus2.MonitorTest"; DBusProxy::builder(&conn) .cache_properties(CacheProperties::No) @@ -100,7 +103,7 @@ async fn become_monitor_client(address: &str, tx: Sender<()>) -> anyhow::Result< let member = header.member(); match msg.message_type() { - MessageType::MethodCall => match member.unwrap().as_str() { + message::Type::MethodCall => match member.unwrap().as_str() { "Hello" => { hello_serial = Some(msg.primary_header().serial_num()); } @@ -109,7 +112,7 @@ async fn become_monitor_client(address: &str, tx: Sender<()>) -> anyhow::Result< } method => panic!("unexpected method call: {}", method), }, - MessageType::MethodReturn => { + message::Type::MethodReturn => { let serial = header.reply_serial(); if serial == hello_serial { hello_serial = None; @@ -119,7 +122,7 @@ async fn become_monitor_client(address: &str, tx: Sender<()>) -> anyhow::Result< panic!("unexpected method return: {}", serial.unwrap()); } } - MessageType::Signal => { + message::Type::Signal => { if let Some(signal) = NameOwnerChanged::from_message(msg.clone()) { let args = signal.args()?; ensure!( diff --git a/tests/multiple_conns.rs b/tests/multiple_conns.rs index 68cb0b8..4125c96 100644 --- a/tests/multiple_conns.rs +++ b/tests/multiple_conns.rs @@ -11,7 +11,7 @@ use rand::{ }; use tokio::{select, sync::oneshot::channel}; use tracing::instrument; -use zbus::ConnectionBuilder; +use zbus::connection; #[tokio::test(flavor = "multi_thread", worker_threads = 8)] #[instrument] @@ -59,7 +59,7 @@ async fn multi_conenct_(socket_addr: &str) { async fn multi_clients_connect(socket_addr: &str) -> anyhow::Result<()> { // Create 10 connections simultaneously. let conns: Vec<_> = (0..10) - .map(|_| ConnectionBuilder::address(socket_addr).unwrap().build()) + .map(|_| connection::Builder::address(socket_addr).unwrap().build()) .collect(); join_all(conns).await;