3 unstable releases
0.2.1 | Dec 2, 2022 |
---|---|
0.2.0 | Apr 28, 2022 |
0.1.0 | Apr 27, 2022 |
#735 in Encoding
14,352 downloads per month
Used in 18 crates
(3 directly)
6KB
96 lines
Alternative serde implementation for bytesize
crate based on its FromStr
implementation for human-readable serializers.
Usage
use bytesize::ByteSize;
use serde::{Serialize, Deserialize};
# fn main() {
#[derive(Serialize, Deserialize)]
struct T {
#[serde(with = "bytesize_serde")]
x: ByteSize,
}
let t: T = serde_json::from_str(r#"{ "x": "5 MB" }"#).unwrap();
assert_eq!(t.x, "5 MB".parse::<ByteSize>().unwrap());
# }
Dependencies
~130–360KB