#Serialization #Deserialization

macro yaserde_derive

Serialization and deserialization macros

20 releases

✓ Uses Rust 2018 edition

0.3.17 May 8, 2020
0.3.14 Mar 25, 2020
0.3.9 Dec 15, 2019
0.3.7 Jan 12, 2019
0.3.1 May 30, 2018

#239 in Encoding

Download history 35/week @ 2020-02-06 53/week @ 2020-02-13 58/week @ 2020-02-20 138/week @ 2020-02-27 43/week @ 2020-03-05 41/week @ 2020-03-12 154/week @ 2020-03-19 389/week @ 2020-03-26 465/week @ 2020-04-02 427/week @ 2020-04-09 119/week @ 2020-04-16 102/week @ 2020-04-23 145/week @ 2020-04-30 176/week @ 2020-05-07 309/week @ 2020-05-14 263/week @ 2020-05-21

726 downloads per month
Used in 3 crates

MIT license

64KB
2K 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_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

~400–720KB
~17K SLoC