zbus-old
zbus-old copied to clipboard
dbus_proxy macro panics when one of the methods is `fn r#type(&self)`
trafficstars
In GitLab by @MaxVerevkin on Oct 13, 2021, 17:43
#[dbus_proxy(
interface = "org.freedesktop.UPower.Device",
default_service = "org.freedesktop.UPower"
)]
trait Device {
/// Type property
#[dbus_proxy(property)]
fn r#type(&self) -> zbus::Result<u32>;
}
Fails:
error: custom attribute panicked
--> src/blocks/battery/zbus_upower.rs:24:1
|
24 | / #[dbus_proxy(
25 | | interface = "org.freedesktop.UPower.Device",
26 | | default_service = "org.freedesktop.UPower"
27 | | )]
| |__^
|
= help: message: `"cached_r#type"` is not a valid identifier
Is this with 1.x or latest 2.0 beta?
Any easy work around is to make use of name attribute to avoid keywords:
#[dbus_proxy(property, name = "Type")]
fn type_(&self) -> zbus::Result<u32>;
See also https://gitlab.freedesktop.org/dbus/zbus/-/issues/133.
In GitLab by @MaxVerevkin on Oct 14, 2021, 15:23
@zeenix Thanks for the workaround! This affects current master branch as well as latest beta.