Implement TryFrom<OwnedValue> for Type
I have the current dbus interface where I omited the non related parts
#[dbus_proxy(
interface = "org.freedesktop.portal.RemoteDesktop",
default_service = "org.freedesktop.portal.Desktop",
default_path = "/org/freedesktop/portal/desktop"
)]
/// The interface lets sandboxed applications create remote desktop sessions.
trait RemoteDesktop {
/// Available source types.
#[dbus_proxy(property)]
fn available_device_types(&self) -> Result<u32>;
}
The result of the available device types is a C enum which looks like this in Rust
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Type)]
#[repr(u32)]
pub enum DeviceType {
Keyboard = 1,
Pointeur = 2,
Touchscreen = 4,
}
Trying to make the output uses it results in the following error
src/desktop/remote_desktop.rs:55:1
|
55 | / #[dbus_proxy(
56 | | interface = "org.freedesktop.portal.RemoteDesktop",
57 | | default_service = "org.freedesktop.portal.Desktop",
58 | | default_path = "/org/freedesktop/portal/desktop"
59 | | )]
| |__^ the trait `std::convert::From<zvariant::OwnedValue>` is not implemented for `desktop::remote_desktop::DeviceType`
|
= note: required because of the requirements on the impl of `std::convert::Into<desktop::remote_desktop::DeviceType>` for `zvariant::OwnedValue`
= note: required because of the requirements on the impl of `std::convert::TryFrom<zvariant::OwnedValue>` for `desktop::remote_desktop::DeviceType`
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
I wonder if it makes sense to provide an OwnedType derive macro that will do the same thing as Type but uses OwnedValue instead of Value?
Edited by Zeeshan Ali Khan