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

zm: ProxyName::new() doesn't need to return a Result


Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
parent c17c85ff
......@@ -67,7 +67,7 @@ trait Notifications {
fn main() -> Result<(), Box<dyn Error>> {
let connection = zbus::Connection::new_session()?;
let proxy = NotificationsProxy::new(&connection)?;
let proxy = NotificationsProxy::new(&connection);
let reply = proxy.notify(
"my-app",
0,
......@@ -106,7 +106,7 @@ impl Greeter {
fn main() -> Result<(), Box<dyn Error>> {
let connection = zbus::Connection::new_session()?;
fdo::DBusProxy::new(&connection)?.request_name(
fdo::DBusProxy::new(&connection).request_name(
"org.zbus.MyGreeter",
fdo::RequestNameFlags::ReplaceExisting.into(),
)?;
......@@ -278,7 +278,7 @@ use zbus::Connection;
use zbus_polkit::policykit1::*;
let connection = Connection::new_system().unwrap();
let proxy = AuthorityProxy::new(&connection).unwrap();
let proxy = AuthorityProxy::new(&connection);
let subject = Subject::new_for_owner(std::process::id(), None, None).unwrap();
let result = proxy.check_authorization(
&subject,
......
......@@ -260,7 +260,7 @@ client.set_desktop_id("org.freedesktop.zbus").unwrap();
client
.connect_location_updated(move |_old, new| {
let location = LocationProxy::new_for_path(&conn, &new)?;
let location = LocationProxy::new_for_path(&conn, &new);
println!(
"Latitude: {}\nLongitude: {}",
location.latitude()?,
......@@ -326,7 +326,7 @@ actually getting set:
# let manager = ManagerProxy::new(&conn).unwrap();
# let client_path = manager.get_client().unwrap();
# let mut client =
# ClientProxy::new_for(&conn, "org.freedesktop.GeoClue2", &client_path).unwrap();
# ClientProxy::new_for(&conn, "org.freedesktop.GeoClue2", &client_path);
# // Gotta do this, sorry!
# client.set_desktop_id("org.freedesktop.zbus").unwrap();
#
......
......@@ -64,7 +64,7 @@ async fn run() -> Result<()> {
fn longitude(&self) -> Result<f64>;
}
let conn = Connection::new_system().await?;
let manager = AsyncManagerProxy::new(&conn)?;
let manager = AsyncManagerProxy::new(&conn);
let mut client = manager.get_client().await?;
// Gotta do this, sorry!
client.set_desktop_id("org.freedesktop.zbus").await?;
......@@ -152,7 +152,7 @@ example again to receive multiple signals on different proxies:
# fn longitude(&self) -> Result<f64>;
# }
# let conn = Connection::new_system().await?;
# let manager = AsyncManagerProxy::new(&conn)?;
# let manager = AsyncManagerProxy::new(&conn);
# let mut client = manager.get_client().await?;
#
// Everything else remains the same before this point.
......
......@@ -115,7 +115,7 @@ trait Notifications {
fn main() -> Result<(), Box<dyn Error>> {
let connection = zbus::Connection::new_session()?;
let proxy = NotificationsProxy::new(&connection)?;
let proxy = NotificationsProxy::new(&connection);
let reply = proxy.notify("my-app", 0, "dialog-information", "A summary", "Some body",
&[], HashMap::new(), 5000)?;
dbg!(reply);
......@@ -173,7 +173,7 @@ trait SystemdManager {
fn main() -> Result<(), Box<dyn Error>> {
let connection = zbus::Connection::new_session()?;
let proxy = SystemdManagerProxy::new(&connection)?;
let proxy = SystemdManagerProxy::new(&connection);
println!("Host architecture: {}", proxy.architecture()?);
println!("Environment:");
for env in proxy.environment()? {
......@@ -254,7 +254,7 @@ trait Location {
fn longitude(&self) -> Result<f64>;
}
let conn = Connection::new_system().unwrap();
let manager = ManagerProxy::new(&conn).unwrap();
let manager = ManagerProxy::new(&conn);
let mut client = manager.get_client().unwrap();
// Gotta do this, sorry!
client.set_desktop_id("org.freedesktop.zbus").unwrap();
......@@ -327,7 +327,7 @@ actually getting set:
# }
#
# let conn = Connection::new_system().unwrap();
# let manager = ManagerProxy::new(&conn).unwrap();
# let manager = ManagerProxy::new(&conn);
# let mut client = manager.get_client().unwrap();
# // Gotta do this, sorry!
# client.set_desktop_id("org.freedesktop.zbus").unwrap();
......
......@@ -22,7 +22,7 @@ use zbus::fdo;
fn main() -> std::result::Result<(), Box<dyn Error>> {
let connection = Connection::new_session()?;
fdo::DBusProxy::new(&connection)?.request_name(
fdo::DBusProxy::new(&connection).request_name(
"org.zbus.MyGreeter",
fdo::RequestNameFlags::ReplaceExisting.into(),
)?;
......@@ -53,7 +53,7 @@ by replacing the loop above with this code:
```rust,no_run
# fn main() -> Result<(), Box<dyn std::error::Error>> {
# let connection = zbus::Connection::new_session()?;
# zbus::fdo::DBusProxy::new(&connection)?.request_name(
# zbus::fdo::DBusProxy::new(&connection).request_name(
# "org.zbus.MyGreeter",
# zbus::fdo::RequestNameFlags::ReplaceExisting.into(),
# )?;
......@@ -132,7 +132,7 @@ impl Greeter {
fn main() -> Result<(), Box<dyn Error>> {
let connection = zbus::Connection::new_session()?;
# fdo::DBusProxy::new(&connection)?.request_name(
# fdo::DBusProxy::new(&connection).request_name(
# "org.zbus.MyGreeter",
# fdo::RequestNameFlags::ReplaceExisting.into(),
# )?;
......
......@@ -685,7 +685,7 @@ impl Connection {
None => {
let match_rule = signal.create_match_rule();
if let Some(match_rule) = &match_rule {
fdo::AsyncDBusProxy::new(&self)?
fdo::AsyncDBusProxy::new(&self)
.add_match(&match_rule)
.await?;
}
......@@ -727,7 +727,7 @@ impl Connection {
if subscription.num_subscribers == 0 {
if let Some(match_rule) = &subscription.match_rule {
fdo::AsyncDBusProxy::new(&self)?
fdo::AsyncDBusProxy::new(&self)
.remove_match(match_rule.as_str())
.await?;
}
......@@ -742,7 +742,7 @@ impl Connection {
}
async fn hello_bus(self) -> Result<Self> {
let name = fdo::AsyncDBusProxy::new(&self)?.hello().await?;
let name = fdo::AsyncDBusProxy::new(&self).hello().await?;
self.0
.unique_name
......
......@@ -618,7 +618,7 @@ impl<'a> Proxy<'a> {
let unique_name = if destination.starts_with(':') || destination == "org.freedesktop.DBus" {
destination.to_string()
} else {
fdo::AsyncDBusProxy::new(&self.inner.conn)?
fdo::AsyncDBusProxy::new(&self.inner.conn)
.get_name_owner(destination)
.await?
};
......@@ -875,7 +875,6 @@ mod tests {
};
fdo::DBusProxy::new(&crate::Connection::from(conn))
.unwrap()
.request_name(&well_known, fdo::RequestNameFlags::ReplaceExisting.into())
.unwrap();
......
......@@ -628,7 +628,7 @@ mod tests {
let owner_change_signaled = Arc::new(Mutex::new(false));
let name_acquired_signaled = Arc::new(Mutex::new(false));
let proxy = fdo::DBusProxy::new(&conn).unwrap();
let proxy = fdo::DBusProxy::new(&conn);
let well_known = "org.freedesktop.zbus.FdoSignalTest";
let unique_name = conn.unique_name().unwrap().to_string();
......
......@@ -45,7 +45,7 @@
//! fn main() -> Result<(), Box<dyn Error>> {
//! let connection = zbus::Connection::new_session()?;
//!
//! let proxy = NotificationsProxy::new(&connection)?;
//! let proxy = NotificationsProxy::new(&connection);
//! let reply = proxy.notify(
//! "my-app",
//! 0,
......@@ -84,7 +84,7 @@
//!
//! fn main() -> Result<(), Box<dyn Error>> {
//! let connection = zbus::Connection::new_session()?;
//! fdo::DBusProxy::new(&connection)?.request_name(
//! fdo::DBusProxy::new(&connection).request_name(
//! "org.zbus.MyGreeter",
//! fdo::RequestNameFlags::ReplaceExisting.into(),
//! )?;
......@@ -545,7 +545,7 @@ mod tests {
.unwrap();
let serial = client_conn.send_message(msg).unwrap();
crate::fdo::DBusProxy::new(&conn).unwrap().get_id().unwrap();
crate::fdo::DBusProxy::new(&conn).get_id().unwrap();
loop {
let msg = conn.receive_message().unwrap();
......
......@@ -797,7 +797,6 @@ mod tests {
let action = Rc::new(Cell::new(NextAction::Nothing));
fdo::DBusProxy::new(&conn)
.unwrap()
.request_name(
"org.freedesktop.MyService",
fdo::RequestNameFlags::ReplaceExisting.into(),
......
......@@ -332,7 +332,6 @@ mod tests {
}
fdo::DBusProxy::new(&conn)
.unwrap()
.request_name(&well_known, fdo::RequestNameFlags::ReplaceExisting.into())
.unwrap();
......
......@@ -230,7 +230,6 @@ mod tests {
let conn = Connection::new_session().unwrap();
fdo::DBusProxy::new(&conn)
.unwrap()
.request_name(
"org.freedesktop.zbus.MultiSignal",
fdo::RequestNameFlags::ReplaceExisting.into(),
......
......@@ -80,7 +80,7 @@ mod utils;
/// trait SomeOtherIface {}
///
/// let connection = Connection::new_session()?;
/// let proxy = SomeIfaceProxy::new(&connection)?;
/// let proxy = SomeIfaceProxy::new(&connection);
/// let _ = proxy.do_this("foo", 32, &Value::new(true));
/// let _ = proxy.set_a_property("val");
///
......@@ -95,7 +95,7 @@ mod utils;
/// assert!(!proxy.disconnect_signal(handler_id)?);
///
/// // Now the same again, but asynchronous.
/// let proxy = AsyncSomeIfaceProxy::new(&connection.into())?;
/// let proxy = AsyncSomeIfaceProxy::new(&connection.into());
/// block_on(async move {
/// let _ = proxy.do_this("foo", 32, &Value::new(true)).await;
/// let _ = proxy.set_a_property("val").await;
......
......@@ -146,9 +146,9 @@ pub fn create_proxy(args: &[NestedMeta], input: &ItemTrait, azync: bool) -> Toke
impl<'c> #proxy_name<'c> {
/// Creates a new proxy with the default service & path.
pub fn new(conn: &#connection) -> ::#zbus::Result<Self> {
pub fn new(conn: &#connection) -> Self {
let conn = &conn.clone().into();
Ok(::#zbus::azync::ProxyBuilder::new(conn).build())
::#zbus::azync::ProxyBuilder::new(conn).build()
}
/// Consumes `self`, returning the underlying `zbus::Proxy`.
......
......@@ -47,7 +47,7 @@ fn test_proxy() {
}
let connection = zbus::Connection::new_session().unwrap();
let proxy = TestProxy::new(&connection).unwrap();
let proxy = TestProxy::new(&connection);
proxy
.connect_signal(move |_arg, other: String| {
println!("{}", other);
......
......@@ -14,7 +14,7 @@
//! use zbus_polkit::policykit1::*;
//!
//! let c = Connection::new_system().unwrap();
//! let p = AuthorityProxy::new(&c).unwrap();
//! let p = AuthorityProxy::new(&c);
//! let subject = Subject::new_for_owner(std::process::id(), None, None).unwrap();
//! let result = p.check_authorization(
//! &subject,
......
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