Yet Another Serializer/Deserializer
Clone or download
Latest commit 54cf32c Jan 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
yaserde release v0.3.7 Jan 12, 2019
yaserde_derive release v0.3.7 Jan 12, 2019
.gitignore ignore OSX DS_Store files Nov 5, 2018
.travis.yml skip serialization if value equals to default Dec 7, 2018
Cargo.toml remove undefined project May 15, 2018
LICENSE Initial commit Apr 9, 2018
README.md skip serialization if value equals to default Dec 7, 2018
rustfmt.toml add fmt definition May 23, 2018

README.md

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