Server example in documentation doesn't work
The issue
The documentation gives this as an example of how a basic dbus-based server might be implemented:
use zbus::{Connection, Result};
use futures_util::stream::TryStreamExt;
// Although we use `async-std` here, you can use any async runtime of choice.
#[async_std::main]
async fn main() -> Result<()> {
let connection = Connection::session()
.await?;
connection
.request_name("org.zbus.MyGreeter")
.await?;
let mut stream = zbus::MessageStream::from(&connection);
while let Some(msg) = stream.try_next().await? {
let msg_header = msg.header()?;
dbg!(&msg);
match msg_header.message_type()? {
zbus::MessageType::MethodCall => {
// real code would check msg_header path(), interface() and member()
// handle invalid calls, introspection, errors etc
let arg: &str = msg.body()?;
connection.reply(&msg, &(format!("Hello {}!", arg))).await?;
break;
}
_ => continue,
}
}
Ok(())
}
However, the attempting to make method calls to the dbus interface defined above results in an error, which will look something like this:
Error: org.freedesktop.DBus.Error.UnknownObject: Unknown object '/org/zbus/MyGreeter'
The issue is present with both the async and blocking versions of zbus's API, and has been reproduced using both busctl --user call
and zbus::blocking::Connection::call_method
.
Edited by jakobrs