serde-extras
A lightweight crate providing utilities for serializing and deserializing types using their string representations with Serde.
Features
- Serialize and deserialize types that implement
ToStringandFromStrvia Serde attributes. - Minimal dependencies and small code footprint.
Usage
Add to your Cargo.toml:
= "0.1"
Annotate your struct fields with Serde's with attribute:
use IpAddr;
use ;
This will serialize the ip field as a string and deserialize it from a string.
Example
use IpAddr;
use ;
use serde_json;
let w = Wrapper ;
let json = to_string.unwrap;
assert_eq!;
let de: Wrapper = from_str.unwrap;
assert_eq!;
Comparison
This crate is a lightweight alternative to a small portion of serde_with. If you only need simple string-based (de)serialization helpers, serde-extras may be a better fit. For more advanced features, consider using serde_with.
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in serde-extras by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.