From d6e7a07cc2d31a28923c852c0a55852c65c778f1 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Arnaud Date: Sun, 13 May 2018 10:12:01 +0200 Subject: [PATCH] describe custom de/ser-ializer --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 3c0e796..f38b295 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,25 @@ This library will support XML de/ser-ializing with all specific features. - [x] **attribute**: this field is defined as an attribute - [x] **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 + +```rust +impl YaDeserialize for MyType { + fn deserialize(reader: &mut yaserde::de::Deserializer) -> Result { + // deserializer code + } +} +``` + +```rust + +impl YaSerialize for MyType { + fn serialize(&self, writer: &mut yaserde::ser::Serializer) -> Result<(), String> { + // serializer code + } +} +```