Crates.io | serde_str |
lib.rs | serde_str |
version | 0.1.0 |
source | src |
created_at | 2018-03-02 15:31:32.517849 |
updated_at | 2018-03-02 15:31:32.517849 |
description | A serde wrapper that stores type using Display and FromStr. |
homepage | https://github.com/tailhook/serde-str |
repository | |
max_upload_size | |
id | 53463 |
size | 20,999 |
Documentation | Github | Crate
A serde wrapper, that can be used to serialize data types using Display
(or .to_string()
) and FromStr.
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_str;
use std::net::IpAddr;
#[derive(Serialize, Deserialize)]
struct Struct {
/// By default IpAddr is serialized the same in human-readable formats
/// like json. This forces the impl even for binary formats.
///
/// More inporantly this is useful for types which don't have serde impl.
#[serde(with = "serde_str")]
ip: IpAddr,
}
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.