#display #serde #serialization #string #from-str

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

#2309 in Encoding

Download history 228/week @ 2024-07-22 304/week @ 2024-07-29 354/week @ 2024-08-05 286/week @ 2024-08-12 312/week @ 2024-08-19 315/week @ 2024-08-26 533/week @ 2024-09-02 430/week @ 2024-09-09 389/week @ 2024-09-16 272/week @ 2024-09-23 270/week @ 2024-09-30 175/week @ 2024-10-07 373/week @ 2024-10-14 128/week @ 2024-10-21 128/week @ 2024-10-28 155/week @ 2024-11-04

784 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

~100–330KB