#serde #string #display #fromstr #serialization

serde_str

A serde wrapper that stores type using Display and FromStr

1 unstable release

Uses old Rust 2015

0.1.0 Mar 2, 2018

#1961 in Encoding

Download history 340/week @ 2023-11-03 453/week @ 2023-11-10 337/week @ 2023-11-17 276/week @ 2023-11-24 209/week @ 2023-12-01 312/week @ 2023-12-08 324/week @ 2023-12-15 246/week @ 2023-12-22 193/week @ 2023-12-29 271/week @ 2024-01-05 387/week @ 2024-01-12 290/week @ 2024-01-19 301/week @ 2024-01-26 301/week @ 2024-02-02 300/week @ 2024-02-09 279/week @ 2024-02-16

1,203 downloads per month
Used in 34 crates (15 directly)

MIT/Apache

9KB
50 lines

Serde Str

Documentation | Github | Crate

A serde wrapper, that can be used to serialize data types using Display (or .to_string()) and FromStr.

Example

#[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,
}

License

Licensed under either of

Contribution

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.

Dependencies

~110–360KB