zbus-old
zbus-old copied to clipboard
Shared interface between dbus_interface and dbus_proxy
A lot of times, codebases have both the service and client side so it'd be ideal with the API declaration (i-e the trait declaration given to the dbus_proxy macro) could be shared between dbus_proxy and dbus_interface. Something like:
#[dbus_interface(interface = "org.blah")]
#[dbus_proxy(interface = "org.blah")]
// Might be better to even provide another macro that combines the above two?
trait Blah {
fn blah(&self, arg: &str) -> Result<usize>;
}
// xmlgen can generate the above part.
struct BlahImpl;
impl Blah for BlahImpl {
fn blah(&self, arg: &str) -> Result<usize> {
Ok(arg.len())
}
}
Related: #118, #225.
In GitLab by @ids1024 on Jan 12, 2022, 01:21
How would such a trait fit with async use cases? That would require different function signatures for methods, and async trait methods are still not supported by Rust.
We already support async traits through the async-trait crate. Both proxy and interface methods are async in 2.0 essentially.
https://gitlab.freedesktop.org/dbus/zbus/-/blob/main/zbus/src/interface.rs#L48