Open zeenix opened 1 year ago
In GitLab by @wynprice999 on Mar 1, 2023, 22:01
It seems like the field names used for deserialization can't be renamed. I would expect using #[zvariant(rename = "...")] would rename the field, but it doesn't appear to have an effect:
#[zvariant(rename = "...")]
From what I can tell, a solution would involve the following line: https://gitlab.freedesktop.org/dbus/zbus/-/blob/main/zvariant_derive/src/value.rs#L111
@wynprice999 Thanks for reporting this. Yeah, renaming should work as you expect.
@turbocooler Hey, this seems right up your alley. ;)
In GitLab by @wynprice999 on Mar 1, 2023, 22:01
It seems like the field names used for deserialization can't be renamed. I would expect using
#[zvariant(rename = "...")]
would rename the field, but it doesn't appear to have an effect:Example expansion
```rust #[derive(DeserializeDict, Value, OwnedValue)] #[zvariant(signature = "dict")] pub struct TrackMetadata { #[zvariant(rename = "otherfield")] pub field1: String, pub field2: String } ``` Expands to the following: ```rs #[zvariant(signature = "dict")] pub struct TrackMetadata { #[zvariant(rename = "otherfield")] pub field1: String, pub field2: String, } ... impl ::std::convert::TryFrom<::zbus::zvariant::OwnedValue> for TrackMetadata { type Error = ::zbus::zvariant::Error; #[inline] fn try_from( value: ::zbus::zvariant::OwnedValue, ) -> ::zbus::zvariant::ResultFrom what I can tell, a solution would involve the following line: https://gitlab.freedesktop.org/dbus/zbus/-/blob/main/zvariant_derive/src/value.rs#L111