Allow usage of generics in dbus_proxy trait
Currently, trying to write such Proxy
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Type)]
#[repr(u32)]
enum ResponseType {
/// Success, the request is carried out
Success = 0,
/// The user cancelled the interaction
Cancelled = 1,
/// The user interaction was ended in some other way
Other = 2,
}
#[dbus_proxy(default_path = "/org/freedesktop/portal/desktop")]
trait Request {
#[dbus_proxy(signal)]
/// A signal emitted when the portal interaction is over.
fn response<T>(&self, response: (ResponseType, T)) -> Result<()>
where
T: serde::de::DeserializeOwned + zvariant::Type;
/// Closes the portal request to which this object refers and ends all related user interaction (dialogs, etc).
/// A Response signal will not be emitted in this case.
fn close(&self) -> Result<()>;
}
Fails with the current issue
error[E0412]: cannot find type `T` in this scope
--> src/request.rs:60:52
|
56 | #[dbus_proxy(default_path = "/org/freedesktop/portal/desktop")]
| --------------------------------------------------------------- similarly named type parameter `H` defined here
...
60 | fn response<T>(&self, response: (ResponseType, T)) -> Result<()>
| ^ help: a type parameter with a similar name exists: `H`
warning: unused import: `ObjectPath`
--> src/request.rs:5:16
|
5 | use zvariant::{ObjectPath, OwnedValue};
| ^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0282]: type annotations needed
--> src/request.rs:60:27
|
60 | fn response<T>(&self, response: (ResponseType, T)) -> Result<()>
| ^^^^^^^^ consider giving `response` a type
error: aborting due to 2 previous errors; 1 warning emitted
Some errors have detailed explanations: E0282, E0412.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `ashpd`
Edited by Bilal Elmoussaoui