gentoo90 / winreg-rs

Rust bindings to MS Windows Registry API
MIT License
168 stars 36 forks source link

Serde decoding fails with subkeys #49

Closed lars-berger closed 1 year ago

lars-berger commented 1 year ago

When decoding via the serialization-serde feature, it fails with DecodeNotImplemented("deserialize_any for keys") even though I'm only interested in certain values (eg. AutoColorization only in this case).

#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct DesktopReg {
  AutoColorization: u32,
}

pub fn decode_example() -> Result<DesktopReg> {
  let hkcu = RegKey::predef(HKEY_CURRENT_USER);
  let desktop_key = hkcu.open_subkey_with_flags("Control Panel\\Desktop", KEY_READ)?;

  let decoded: DesktopReg = desktop_key.decode()?;
  Ok(decoded)
}
gentoo90 commented 1 year ago

Fixed in winreg-0.11.0.

PS: on my machine there's no AutoColorization value in this registry key, so you might want to use Option<u32>.