33 releases

0.10.0 Feb 5, 2024
0.9.1 Dec 31, 2023
0.8.0 Mar 25, 2022
0.7.1 Jul 6, 2021
0.3.1 May 30, 2018

#128 in Parser implementations

Download history 9559/week @ 2024-01-21 7391/week @ 2024-01-28 4513/week @ 2024-02-04 3658/week @ 2024-02-11 3420/week @ 2024-02-18 4856/week @ 2024-02-25 9468/week @ 2024-03-03 8972/week @ 2024-03-10 7144/week @ 2024-03-17 5977/week @ 2024-03-24 3125/week @ 2024-03-31 2456/week @ 2024-04-07 3510/week @ 2024-04-14 2989/week @ 2024-04-21 6591/week @ 2024-04-28 7893/week @ 2024-05-05

21,120 downloads per month
Used in 45 crates (23 directly)

MIT license

23KB
483 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. More details...
  • skip_serializing_if: Skip the serialisation for this field if the condition is true. More details...
  • 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

~290–550KB
~12K SLoC