dbus2 / zbus-old

Rust D-Bus crate.
https://gitlab.freedesktop.org/dbus/zbus
Other
49 stars 13 forks source link

fix: broken example in docs #343

Closed zeenix closed 1 year ago

zeenix commented 1 year ago

In GitLab by @OliverNChalk on May 6, 2023, 20:11

A few of the examples binds a session to _ which immediately destructs in rust. As such, the example does not behave as expected (the user is unable to find the dbus service/object using command line tools, nor can they message it).

The fix is trivial:

0001-docs-fix-broken-example-that-immediately-destructed-.patch

From 264bc7f30a44f6638d6505359304521beb9a9321 Mon Sep 17 00:00:00 2001
From: OliverNChalk <11343499+OliverNChalk@users.noreply.github.com>
Date: Sat, 6 May 2023 13:02:30 -0500
Subject: [PATCH] docs: fix broken example that immediately destructed session

---
From bb4f230cc8c9a2b70a9c3063f8b68a83e1e6813c Mon Sep 17 00:00:00 2001
From: OliverNChalk <11343499+OliverNChalk@users.noreply.github.com>
Date: Sat, 6 May 2023 13:02:30 -0500
Subject: [PATCH] docs: fix broken example that immediately destructed session

---
 book/src/blocking.md | 2 +-
 book/src/server.md   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/book/src/blocking.md b/book/src/blocking.md
index 9b1f2093..0dd8e815 100644
--- a/book/src/blocking.md
+++ b/book/src/blocking.md
@@ -188,7 +188,7 @@ fn main() -> Result<(), Box<dyn Error>> {
         done: event_listener::Event::new(),
     };
     let done_listener = greeter.done.listen();
-    let _ = ConnectionBuilder::session()?
+    let _handle = ConnectionBuilder::session()?
         .name("org.zbus.MyGreeter")?
         .serve_at("/org/zbus/MyGreeter", greeter)?
         .build()?;
diff --git a/book/src/server.md b/book/src/server.md
index 552b2de5..449e09d6 100644
--- a/book/src/server.md
+++ b/book/src/server.md
@@ -163,7 +163,7 @@ setting up your interfaces and requesting names, and not have to care about this
 #
 # #[async_std::main]
 # async fn main() -> Result<()> {
-    let _ = ConnectionBuilder::session()?
+    let _handle = ConnectionBuilder::session()?
         .name("org.zbus.MyGreeter")?
         .serve_at("/org/zbus/MyGreeter", Greeter)?
         .build()
@@ -262,7 +262,7 @@ async fn main() -> Result<()> {
         done: event_listener::Event::new(),
     };
     let done_listener = greeter.done.listen();
-    let _ = ConnectionBuilder::session()?
+    let _handle = ConnectionBuilder::session()?
         .name("org.zbus.MyGreeter")?
         .serve_at("/org/zbus/MyGreeter", greeter)?
         .build()
--
2.40.0
zeenix commented 1 year ago

Thanks. I thought I fixed it everywhere. Can you please provide a merge request?

zeenix commented 1 year ago

In GitLab by @OliverNChalk on May 6, 2023, 22:19

I think new freedesktop gitlab accounts cannot create repositories. I get the following when attempting to fork (hence the patch submission):

image

zeenix commented 1 year ago

ugh.. I think you need to verify your account or something if I'm not mistaken. It's all due to spam. The plan is to move to Github but seems I need to really expedite our move now. I'll commit your patch for you for now.

zeenix commented 1 year ago

mentioned in commit 343e44547ffc99a08d80faf6d59721fe8443a234