zbus::dbus_interface macro assuming zvariant crate
I run the following code from the book in a standalone app:
use std::error::Error;
use zbus::dbus_interface;
use std::convert::TryInto;
struct Greeter;
#[dbus_interface(name = "org.zbus.MyGreeter1")]
impl Greeter {
fn say_hello(&self, name: &str) -> String {
format!("Hello {}!", name)
}
}
fn main() -> Result<(), Box<dyn Error>> {
let connection = zbus::Connection::new_session()?;
let mut object_server = zbus::ObjectServer::new(&connection);
object_server.at(&"/org/zbus/MyGreeter".try_into()?, Greeter);
loop {
if let Err(err) = object_server.try_handle_next() {
eprintln!("{}", err);
}
}
}
and ended up with compiler errors:
error[E0432]: unresolved import `zvariant`
--> src/main.rs:7:1
|
7 | #[dbus_interface(name = "org.zbus.MyGreeter1")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type or module `zvariant`
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared type or module `zvariant`
--> src/main.rs:7:1
|
7 | #[dbus_interface(name = "org.zbus.MyGreeter1")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type or module `zvariant`
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: no function or associated item named `signature` found for reference `&str` in the current scope
--> src/main.rs:7:1
|
7 | #[dbus_interface(name = "org.zbus.MyGreeter1")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `&str`
|
= help: items from traits can only be used if the trait is in scope
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
1 | use zvariant::r#type::Type;
|
error[E0599]: no function or associated item named `signature` found for struct `std::string::String` in the current scope
--> src/main.rs:7:1
|
7 | #[dbus_interface(name = "org.zbus.MyGreeter1")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `std::string::String`
|
= help: items from traits can only be used if the trait is in scope
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
1 | use zvariant::r#type::Type;
|
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0432, E0433, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `zbus-test`.
Workaround is adding an explicit dep on zvariant
crate but that shouldn't be needed.