dbus_interface property setters fails with custom type
If you are writing a dbus interface, and you have a custom wrapper type like
#[derive(Serialize, Deserialize, Type, Value)]
pub struct MyCustomType(String);
Passing that type to your interface to set a property makes it fail
#[derive(Debug)]
pub struct MyInterface {}
#[dbus_interface(name = "org.freedesktop.MySuperInterface")]
impl MyInterface {
#[dbus_interface(property)]
fn my_custom_type(&self) -> MyCustomType {
todo!()
}
#[dbus_interface(property)]
fn set_my_custom_type(&mut self, my_custom_type: MyCustomType) {
}
}
The error would be something like
error[E0308]: mismatched types
--> src/service/client.rs:17:1
|
17 | #[dbus_interface(name = "org.freedesktop.GeoClue2.Client")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `zbus::zvariant::Error`, found enum `Infallible`
|
note: return type inferred to be `zbus::zvariant::Error` here
--> src/service/client.rs:17:1
|
17 | #[dbus_interface(name = "org.freedesktop.GeoClue2.Client")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the attribute macro `dbus_interface` (in Nightly builds, run with -Z macro-backtrace for more info)
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
I tend to believe it is caused by this https://gitlab.freedesktop.org/dbus/zbus/-/blob/main/zbus_macros/src/iface.rs#L236 but who knows