Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uid should be supported in XML Plist #58

Open
Artoria2e5 opened this issue Apr 26, 2021 · 1 comment
Open

Uid should be supported in XML Plist #58

Artoria2e5 opened this issue Apr 26, 2021 · 1 comment

Comments

@Artoria2e5
Copy link

Artoria2e5 commented Apr 26, 2021

In Apple's implementation, Uid is supported in XML Plists by transforming it into a dictionary with one entry (key CF$UID, value integer). Deserialization transparently turns it back into a UID. rust-plist currently does neither.

For completeness, CF$UID is also used in GNUStep for the two ASCII formats, so the deserialization step can probably just be put in deserialize_any. I haven't checked what happens when you ask plutil to use JSON to represent a UID yet.

@ebarnard
Copy link
Owner

Ideally this should work for both serde (de)serialisation and Value.

For writing/serializing UIDs to XML the approprate code just needs to go here:

fn write_uid(&mut self, _value: Uid) -> Result<(), Error> {

something like:

self.write_start_dictionary(Some(1))?;
self.write_string("CF$UID")?;
self.write_write_integer(uid)?;
self.write_end_collection()

Reading is a bit trickier, as the XML reader will need some sort of lookahead. It would probably be better to implement it as an Event iterator transformer that transforms:

StartDictionary
StringValue("CF$UID")
IntegerValue(uid)
EndDictionary

into:

UidValue(uid)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants