29 releases

0.8.0 Mar 25, 2022
0.7.1 Jul 6, 2021
0.7.0 May 31, 2021
0.6.0 Feb 8, 2021
0.3.1 May 30, 2018

#9 in #deserialization

Download history 1783/week @ 2022-06-04 1816/week @ 2022-06-11 1560/week @ 2022-06-18 2148/week @ 2022-06-25 1731/week @ 2022-07-02 2334/week @ 2022-07-09 2272/week @ 2022-07-16 2593/week @ 2022-07-23 2489/week @ 2022-07-30 2638/week @ 2022-08-06 2787/week @ 2022-08-13 2820/week @ 2022-08-20 2521/week @ 2022-08-27 3373/week @ 2022-09-03 2875/week @ 2022-09-10 2304/week @ 2022-09-17

11,452 downloads per month
Used in 20 crates (11 directly)

MIT license

20KB
477 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: Exclude this field from the serialized output
  • 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–370KB