Closed zeenix closed 1 year ago
In GitLab by @msandova on Jan 4, 2023, 18:31
The following test fails
#[test]
fn kebap_case() {
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, Type)]
#[zvariant(signature = "s")]
/// Where to set the wallpaper on.
pub enum SetOn {
/// Set the wallpaper only on the lock-screen.
Lockscreen,
/// Set the wallpaper only on the background.
Background,
/// Set the wallpaper on both lock-screen and background.
Both,
}
#[derive(DeserializeDict, PartialEq, SerializeDict, Type, Debug)]
#[zvariant(signature = "dict")]
pub struct TestDeserializeDictKebabCase {
#[zvariant(rename = "show-preview")]
pub show_preview: Option<bool>,
#[zvariant(rename = "set-on")]
pub set_on: Option<SetOn>,
}
let test = TestDeserializeDictKebabCase {
show_preview: None,
set_on: Some(SetOn::Lockscreen)
};
let ctxt = Context::<LE>::new_dbus(0);
let mut map = HashMap::new();
map.insert("set-on", Value::from("lockscreen"));
let encoded = to_bytes(ctxt, &map).unwrap();
let decoded: Result<TestDeserializeDictKebabCase> = from_slice(&encoded, ctxt);
assert_eq!(
decoded.unwrap(),
test
);
}
note that using "Lockscreen" instead of "lockstreen" works.
Note that using #[serde(rename_all = "kebab-case")]
also fixed the issue, but idk if it should be needed in the first place.
In GitLab by @msandova on Jan 4, 2023, 18:53
Closing as #[serde(rename_all = "kebab-case")]
(or lowercase) fixes it.
In GitLab by @msandova on Jan 3, 2023, 23:17
I have
and when doing
I am getting
None
on the SetOn. Note that the portal correctly getsboth
see https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.impl.portal.Wallpaper