Closed ephraimkunz closed 3 years ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
yaserde_derive/src/lib.rs | 0 | 2 | 0.0% | ||
yaserde_derive/src/ser/expand_struct.rs | 0 | 3 | 0.0% | ||
yaserde_derive/src/de/expand_struct.rs | 0 | 5 | 0.0% | ||
<!-- | Total: | 14 | 24 | 58.33% | --> |
Totals | |
---|---|
Change from base Build 272: | 0.1% |
Covered Lines: | 1138 |
Relevant Lines: | 1905 |
Any ideas if / when someone could take a look at this PR? No huge rush, but I'm working on a library that depends on these changes and I'd like to avoid having to publish a fork of yaserde if possible.
I use several of the same Rust structs for both JSON and XML serialization. I need certain properties in these structs to be optional for JSON serialization, but use the "text" attribute for XML. Previously this wasn't possible as yaserde didn't support the "text" attribute on anything but String and types that implemented
Into<TokenStream>
.This PR adds support for serializing / deserializing the "text" of an XML tag into
Option<String>
.Serialization
If an
Option<String>
is None, an empty string (the String Default impl) is written. If anOption<String>
is Some, the inner string is written.Deserialization
If the XML text is an empty string,
None
is produced. Else,Some<text>
is produced.