bookdata::util

Module serde_string

Source
Expand description

Utility module for serializing with to/from string.

This module is designed to be used with #[serde(with)], as in:

#[derive(Serialize, Deserialize, Debug)]
struct MyStruct {
  #[serde(with="bookdata::util::serde_string")]
  value: u64
}

let jsv = to_value(MyStruct { value: 72 }).unwrap();
assert_eq!(jsv, json!({
  "value": "72"
}));

It will use ToString and FromStr to serialize and deserialize the data.

Structs§

Functions§