Implement Deserialize and Serialize for plist::Dictionary and plist::Value#70
Conversation
|
Hi, thanks for the PR. Sorry, I completely forgot about it. I'll have a look at it in the next couple of days. |
|
Tried this out and it's working for me in a local project, @ebarnard if you get time to take a look it would be great to get this merged. |
|
Looks good and I'm happy to merge this. I'd like to get Serialisation is already working thanks to: Line 111 in e06e436 Deserialisation just needs the visitor to implement Line 247 in e06e436 |
|
I'm not sure why tests aren't being run but a push usually fixes that. |
|
I'll give this another try, with your hint to implement |
|
This is probably very simple, but I'm not familiar with the internals of serde and I get confused when I try to understand the relationship between visitors and deserializers. It seems the deserializer calls the visitor which calls the deserializer which calls the visitor which calls the deserializer.... If I understand your suggestion, I should add a method like this to the fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Value, D::Error>
where
D: Deserializer<'de>,
{
todo!();
}Then I should "switch on the newtype name", but this method doesn't have access to the newtype name. The However, it's not clear to me whether I should
Can someone please point me in the right direction? Thanks! |
|
I thought there was a way for a I can think of a few other ways of doing this, but none are particularly nice so happy to merge as is, although you might have to wait a little bit for a release. |
|
I'd like to get this right, but I don't really have a strategy at the moment. I'd say go ahead and merge it if you're happy with it. Do you need me to make another push or something to get the tests to run? (It looks like tests are failing because they consider |
|
Serde is only enabled with #[cfg(feature = “serde”)] which is why the tests are failing. I suggest putting all the serde stuff in a module like is done in Line 28 in 9ed64da |
|
I've moved code around so that the tests run. I think this is ready for merging. |
|
Looks great, thanks for doing all this work |
Implements serialization and deserialization of the Dictionary and Value types.
This fixes the nested-dictionary deserialization issue discussed in #54, and also allows plist files to be read and written as general
Dictionarystructs rather than as custom structs.All the existing tests passed, and I don't think I've made any changes that would affect any existing code that uses this crate.
There are two limitations to this implementation:
Dateelements in a plist are deserialized asStringelements in the dictionary.Uidelements are deserialized asIntegerelements in the dictionary.I tried to figure out how to fix these issues, but gave up. I think
plist::value::Value::deserialize()orde:Deserializer::deserialize_any()need a change to properly handle these two newstruct types. However, even with these limitations, this code is useful. Maybe someone else can figure out how to complete the implementation forDateandUid