39 releases

0.12.0 Nov 5, 2024
0.11.1 Sep 16, 2024
0.10.1 Jun 5, 2024
0.10.0 Feb 5, 2024
0.3.1 May 30, 2018

#864 in Procedural macros

Download history 6149/week @ 2024-09-28 5491/week @ 2024-10-05 4496/week @ 2024-10-12 5365/week @ 2024-10-19 4777/week @ 2024-10-26 6045/week @ 2024-11-02 5029/week @ 2024-11-09 4908/week @ 2024-11-16 4603/week @ 2024-11-23 5260/week @ 2024-11-30 5263/week @ 2024-12-07 4873/week @ 2024-12-14 3017/week @ 2024-12-21 2184/week @ 2024-12-28 4303/week @ 2025-01-04 4665/week @ 2025-01-11

14,943 downloads per month
Used in 46 crates (20 directly)

MIT license

86KB
2.5K SLoC

yaserde   Latest Version

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

~0.7–1.3MB
~29K SLoC