36 releases

new 0.11.0 Aug 31, 2024
0.10.1 Jun 5, 2024
0.10.0 Feb 5, 2024
0.9.1 Dec 31, 2023
0.3.1 May 30, 2018

#796 in Procedural macros

Download history 9502/week @ 2024-05-16 9237/week @ 2024-05-23 5264/week @ 2024-05-30 3252/week @ 2024-06-06 3350/week @ 2024-06-13 2990/week @ 2024-06-20 5522/week @ 2024-06-27 8738/week @ 2024-07-04 9076/week @ 2024-07-11 9861/week @ 2024-07-18 9710/week @ 2024-07-25 3374/week @ 2024-08-01 3817/week @ 2024-08-08 4120/week @ 2024-08-15 4582/week @ 2024-08-22 6337/week @ 2024-08-29

19,560 downloads per month
Used in 48 crates (21 directly)

MIT license

91KB
2.5K SLoC

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

~2MB
~43K SLoC