Commit 0ae31539 authored by Marc-André Lureau's avatar Marc-André Lureau
Browse files

Use the ProxyName::builder()


Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
parent 691c6a54
......@@ -22,7 +22,7 @@ and proxy:
```rust,no_run
use futures_util::future::FutureExt;
use zbus::{azync::Connection, azync::ProxyBuilder, dbus_proxy, Result};
use zbus::{azync::Connection, dbus_proxy, Result};
use zvariant::{ObjectPath, OwnedObjectPath};
# async_io::block_on(run()).unwrap();
......@@ -75,7 +75,7 @@ async fn run() -> Result<()> {
let conn = conn.clone();
async move {
let location: AsyncLocationProxy<'_> = ProxyBuilder::new(&conn).path(new)?.build();
let location = AsyncLocationProxy::builder(&conn).path(new)?.build();
println!(
"Latitude: {}\nLongitude: {}",
location.latitude().await?,
......@@ -110,7 +110,7 @@ example again to receive multiple signals on different proxies:
```rust,no_run
# use futures_util::future::FutureExt;
# use zbus::{azync::Connection, azync::ProxyBuilder, dbus_proxy, Result};
# use zbus::{azync::Connection, dbus_proxy, Result};
# use zvariant::{ObjectPath, OwnedObjectPath};
#
# async_io::block_on(run()).unwrap();
......@@ -158,7 +158,7 @@ example again to receive multiple signals on different proxies:
// Everything else remains the same before this point.
client.set_desktop_id("org.freedesktop.zbus").await?;
let props: zbus::fdo::AsyncPropertiesProxy<'_> = zbus::azync::ProxyBuilder::new(&conn)
let props = zbus::fdo::AsyncPropertiesProxy::builder(&conn)
.destination("org.freedesktop.GeoClue2")
.path(client.path())?
.build();
......@@ -178,7 +178,7 @@ example again to receive multiple signals on different proxies:
let conn = conn.clone();
async move {
let location: AsyncLocationProxy<'_> = ProxyBuilder::new(&conn.clone().into())
let location = AsyncLocationProxy::builder(&conn)
.path(new)?
.build();
println!(
......
......@@ -213,7 +213,7 @@ Let's look at this API in action, with an example where we get our location from
[Geoclue](https://gitlab.freedesktop.org/geoclue/geoclue/-/blob/master/README.md):
```rust,no_run
use zbus::{Connection, dbus_proxy, Result, azync::ProxyBuilder};
use zbus::{Connection, dbus_proxy, Result};
use zvariant::{ObjectPath, OwnedObjectPath};
#[dbus_proxy(
......@@ -261,7 +261,7 @@ client.set_desktop_id("org.freedesktop.zbus").unwrap();
client
.connect_location_updated(move |_old, new| {
let location: LocationProxy<'_> = ProxyBuilder::new(&conn.clone().into())
let location = LocationProxy::builder(&conn)
.path(new.as_str())?
.build();
println!(
......@@ -291,7 +291,7 @@ by watching for `Active` property (that we must set to be able to get location f
actually getting set:
```rust,no_run
# use zbus::{Connection, dbus_proxy, Result, azync::ProxyBuilder};
# use zbus::{Connection, dbus_proxy, Result};
# use zvariant::{ObjectPath, OwnedObjectPath};
#
# #[dbus_proxy(
......@@ -336,7 +336,7 @@ actually getting set:
let conn_clone = conn.clone();
client.connect_location_updated(move |_old, new| {
let location: LocationProxy<'_> = ProxyBuilder::new(&conn_clone.clone().into())
let location = LocationProxy::builder(&conn_clone)
.destination("org.freedesktop.GeoClue2")
.path(new.as_str())?
.build();
......@@ -349,7 +349,7 @@ client.connect_location_updated(move |_old, new| {
Ok(())
}).unwrap();
let props: zbus::fdo::PropertiesProxy<'_> = ProxyBuilder::new(&conn.clone().into())
let props = zbus::fdo::PropertiesProxy::builder(&conn)
.destination("org.freedesktop.GeoClue2")
.path(client.path()).unwrap()
.build();
......
......@@ -293,7 +293,7 @@ impl<'a> Proxy<'a> {
///
/// See the [xml](xml/index.html) module for parsing the result.
pub async fn introspect(&self) -> fdo::Result<String> {
let proxy: AsyncIntrospectableProxy<'_> = ProxyBuilder::new(&self.inner.conn)
let proxy = AsyncIntrospectableProxy::builder(&self.inner.conn)
.destination(self.inner.destination.as_ref())
.path(&self.inner.path)?
.build();
......@@ -308,7 +308,7 @@ impl<'a> Proxy<'a> {
where
T: TryFrom<OwnedValue>,
{
let proxy: AsyncPropertiesProxy<'_> = ProxyBuilder::new(&self.inner.conn)
let proxy = AsyncPropertiesProxy::builder(&self.inner.conn)
.destination(self.inner.destination.as_ref())
.path(&self.inner.path)?
.build();
......@@ -327,7 +327,7 @@ impl<'a> Proxy<'a> {
where
T: Into<Value<'t>>,
{
let proxy: AsyncPropertiesProxy<'_> = ProxyBuilder::new(&self.inner.conn)
let proxy = AsyncPropertiesProxy::builder(&self.inner.conn)
.destination(self.inner.destination.as_ref())
.path(&self.inner.path)?
.build();
......
......@@ -606,7 +606,7 @@ mod tests {
) -> zbus::Result<(OwnedValue, OwnedObjectPath)>;
}
let proxy: SecretProxy<'_> = zbus::azync::ProxyBuilder::new(&conn.clone().into())
let proxy = SecretProxy::builder(&conn)
.destination(&service_name)
.path("/org/freedesktop/secrets")
.unwrap()
......
......@@ -551,8 +551,7 @@ mod tests {
use zvariant::derive::Type;
use crate::{
azync::ProxyBuilder, dbus_interface, dbus_proxy, fdo, Connection, MessageHeader,
MessageType, ObjectServer,
dbus_interface, dbus_proxy, fdo, Connection, MessageHeader, MessageType, ObjectServer,
};
#[derive(Deserialize, Serialize, Type)]
......@@ -707,12 +706,12 @@ mod tests {
fn my_iface_test(tx: Sender<()>) -> std::result::Result<u32, Box<dyn Error>> {
let conn = Connection::new_session()?;
let proxy: MyIfaceProxy<'_> = ProxyBuilder::new(&conn.clone().into())
let proxy = MyIfaceProxy::builder(&conn)
.destination("org.freedesktop.MyService")
.path("/org/freedesktop/MyService")?
.build();
let props_proxy: zbus::fdo::PropertiesProxy<'_> = ProxyBuilder::new(&conn.clone().into())
let props_proxy = zbus::fdo::PropertiesProxy::builder(&conn)
.destination("org.freedesktop.MyService")
.path("/org/freedesktop/MyService")?
.build();
......@@ -774,7 +773,7 @@ mod tests {
let val = proxy.ping()?;
proxy.create_obj("MyObj")?;
let my_obj_proxy: MyIfaceProxy<'_> = ProxyBuilder::new(&conn.clone().into())
let my_obj_proxy = MyIfaceProxy::builder(&conn)
.destination("org.freedesktop.MyService")
.path("/zbus/test/MyObj")?
.build();
......
......@@ -154,7 +154,7 @@ impl<'r, 'p> SignalReceiver<'r, 'p> {
#[cfg(test)]
mod tests {
use super::*;
use crate::{azync::ProxyBuilder, dbus_interface, dbus_proxy, fdo};
use crate::{dbus_interface, dbus_proxy, fdo};
use std::{
cell::RefCell,
rc::Rc,
......@@ -172,7 +172,7 @@ mod tests {
let conn = Connection::new_session()?;
let mut receiver = SignalReceiver::new(conn.clone());
let proxy1: MultiSignalProxy<'_> = ProxyBuilder::new(&conn.clone().into())
let proxy1 = MultiSignalProxy::builder(&conn)
.destination("org.freedesktop.zbus.MultiSignal")
.path("/org/freedesktop/zbus/MultiSignal/1")?
.build();
......@@ -185,7 +185,7 @@ mod tests {
})?;
receiver.receive_for(&proxy1)?;
let proxy2: MultiSignalProxy<'_> = ProxyBuilder::new(&conn.clone().into())
let proxy2 = MultiSignalProxy::builder(&conn)
.destination("org.freedesktop.zbus.MultiSignal")
.path("/org/freedesktop/zbus/MultiSignal/2")?
.build();
......
......@@ -269,7 +269,7 @@ fn gen_proxy_method_call(
&(#(#args),*),
)
#wait?;
let proxy: #proxy<'_> = ::#zbus::azync::ProxyBuilder::new(&self.0.connection().clone().into())
let proxy = #proxy::builder(&self.0.connection())
.path(object_path)?
.build();
Ok(proxy)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment