yaserde/README.md
2018-05-13 10:12:01 +02:00

1.0 KiB

yaserde

Yet Another Serializer/Deserializer

Goal

This library will support XML de/ser-ializing with all specific features.

Supported types

  • Struct
  • Vec
  • Enum
  • Enum with complex types
  • Option

Decorators

  • root: rename the based element. Used only at the XML root.
  • rename: be able to rename a field
  • attribute: this field is defined as an attribute
  • text: this field match to the text content
  • namespace: defines the namespace of the field

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
  }
}