17 releases

new 0.3.14 Mar 25, 2020
0.3.10 Jan 9, 2020
0.3.9 Dec 15, 2019
0.3.7 Jan 12, 2019
0.3.1 May 30, 2018

#101 in Encoding

Download history 64/week @ 2019-12-01 440/week @ 2019-12-08 21/week @ 2019-12-15 21/week @ 2019-12-22 3/week @ 2019-12-29 26/week @ 2020-01-05 25/week @ 2020-01-12 64/week @ 2020-01-19 6/week @ 2020-01-26 22/week @ 2020-02-02 30/week @ 2020-02-09 54/week @ 2020-02-16 162/week @ 2020-02-23 8/week @ 2020-03-01 56/week @ 2020-03-08 52/week @ 2020-03-15

217 downloads per month

MIT license

15KB
381 lines

yaserde   Build Status Latest Version Coverage Status

Yet Another Serializer/Deserializer specialized for XML

Goal

This library will support XML de/ser-ializing with all specific features.

Supported types

  • Struct
  • Vec
  • Enum
  • Enum with complex types
  • Option
  • String
  • bool
  • number (u8, i8, u32, i32, f32, f64)

Attributes

  • attribute: this field is defined as an attribute
  • default: defines the default function to init the field
  • flatten: Flatten the contents of the field
  • namespace: defines the namespace of the field
  • rename: be able to rename a field
  • root: rename the based element. Used only at the XML root.
  • skip_serializing_if: Skip the serialisation for this field if the condition is true
  • text: this field match to the text content

Custom De/Ser-rializer

Any type can define a custom deserializer and/or serializer. To implement it, define the implementation of YaDeserialize/YaSerialize

impl YaDeserialize for MyType {
  fn deserialize<R: Read>(reader: &mut yaserde::de::Deserializer<R>) -> Result<Self, String> {
    // deserializer code
  }
}

impl YaSerialize for MyType {
  fn serialize<W: Write>(&self, writer: &mut yaserde::ser::Serializer<W>) -> Result<(), String> {
    // serializer code
  }
}

Dependencies

~230–375KB