Skip to content

Using nested plist::Dictionary with serde? #54

@madig

Description

@madig

The following code does not compile. Is there a way to use plist::Dictionary in a nested way?

use plist;
#[macro_use]
extern crate serde_derive;

fn main() {
    #[derive(Deserialize)]
    struct LayerinfoData {
        color: Option<String>,
        lib: Option<plist::Dictionary>,
    }

    let lib_dict: LayerinfoData = plist::from_bytes(r#"
    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>color</key>
    <string>1,0.75,0,0.7</string>
    <key>lib</key>
    <dict>
      <key>com.typemytype.robofont.segmentType</key>
      <string>curve</string>
    </dict>
  </dict>
</plist>
"#.as_bytes()).unwrap();

    println!("{:?}, {:?}.", lib_dict.color, lib_dict.lib);
}

Compiler output:

error[E0277]: the trait bound `plist::dictionary::Dictionary: fontinfo::_IMPL_DESERIALIZE_FOR_FontInfo::_serde::Deserialize<'_>` is not satisfied
  --> src/layer.rs:75:17
   |
75 |                 lib: Option<plist::Dictionary>,
   |                 ^^^ the trait `fontinfo::_IMPL_DESERIALIZE_FOR_FontInfo::_serde::Deserialize<'_>` is not implemented for `plist::dictionary::Dictionary`
   |
   = note: required because of the requirements on the impl of `fontinfo::_IMPL_DESERIALIZE_FOR_FontInfo::_serde::Deserialize<'_>` for `std::option::Option<plist::dictionary::Dictionary>`
   = note: required by `fontinfo::_IMPL_DESERIALIZE_FOR_FontInfo::_serde::de::SeqAccess::next_element`

error[E0277]: the trait bound `plist::dictionary::Dictionary: fontinfo::_IMPL_DESERIALIZE_FOR_FontInfo::_serde::Deserialize<'_>` is not satisfied
  --> src/layer.rs:75:17
   |
75 |                 lib: Option<plist::Dictionary>,
   |                 ^^^ the trait `fontinfo::_IMPL_DESERIALIZE_FOR_FontInfo::_serde::Deserialize<'_>` is not implemented for `plist::dictionary::Dictionary`
   |
   = note: required because of the requirements on the impl of `fontinfo::_IMPL_DESERIALIZE_FOR_FontInfo::_serde::Deserialize<'_>` for `std::option::Option<plist::dictionary::Dictionary>`
   = note: required by `fontinfo::_IMPL_DESERIALIZE_FOR_FontInfo::_serde::de::MapAccess::next_value`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions