From 33bd852e688cca13361e005360aede254625ae73 Mon Sep 17 00:00:00 2001 From: Astariul Date: Wed, 12 Apr 2023 16:32:26 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20doc=20about=20serde=20and?= =?UTF-8?q?=20how=20to=20use?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/serialization.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/serialization.rs b/src/serialization.rs index 87b98c2..af3d40e 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -5,6 +5,16 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::borrow::{Borrow, Cow}; impl Serialize for PatriciaSet { + /// In order to serialize a [PatriciaSet], make sure you installed the crate + /// with the feature `serde`. + /// + /// For example, in your `Cargo.toml`: + /// ```toml + /// [dependencies] + /// patricia_tree = { version = "0.5.5", features = ["serde"] } + /// ``` + /// + /// Read more about serialization / deserialization at the [serde] crate. fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -14,6 +24,16 @@ impl Serialize for PatriciaSet { } impl Serialize for PatriciaMap { + /// In order to serialize a [PatriciaMap], make sure you installed the crate + /// with the feature `serde`. + /// + /// For example, in your `Cargo.toml`: + /// ```toml + /// [dependencies] + /// patricia_tree = { version = "0.5.5", features = ["serde"] } + /// ``` + /// + /// Read more about serialization / deserialization at the [serde] crate. fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -52,6 +72,16 @@ impl Serialize for Node { } impl<'de> Deserialize<'de> for PatriciaSet { + /// In order to deserialize a [PatriciaSet], make sure you installed the crate + /// with the feature `serde`. + /// + /// For example, in your `Cargo.toml`: + /// ```toml + /// [dependencies] + /// patricia_tree = { version = "0.5.5", features = ["serde"] } + /// ``` + /// + /// Read more about serialization / deserialization at the [serde] crate. fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, @@ -61,6 +91,16 @@ impl<'de> Deserialize<'de> for PatriciaSet { } impl<'de, T: Deserialize<'de>> Deserialize<'de> for PatriciaMap { + /// In order to serialize a [PatriciaMap], make sure you installed the crate + /// with the feature `serde`. + /// + /// For example, in your `Cargo.toml`: + /// ```toml + /// [dependencies] + /// patricia_tree = { version = "0.5.5", features = ["serde"] } + /// ``` + /// + /// Read more about serialization / deserialization at the [serde] crate. fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>,