38 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

#186 in Parser implementations

Download history 5000/week @ 2024-11-18 4511/week @ 2024-11-25 5629/week @ 2024-12-02 5281/week @ 2024-12-09 5153/week @ 2024-12-16 2874/week @ 2024-12-23 2306/week @ 2024-12-30 4442/week @ 2025-01-06 5937/week @ 2025-01-13 5813/week @ 2025-01-20 5180/week @ 2025-01-27 5669/week @ 2025-02-03 5634/week @ 2025-02-10 5339/week @ 2025-02-17 6668/week @ 2025-02-24 6129/week @ 2025-03-03

24,066 downloads per month
Used in 47 crates (25 directly)

MIT license

25KB
528 lines

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

~285–485KB