#byte-size #human-readable #deserialize #from-str

bytesize-serde

Alternative serde implementation for bytesize crate based on its FromStr

3 unstable releases

0.2.1 Dec 2, 2022
0.2.0 Apr 28, 2022
0.1.0 Apr 27, 2022

#736 in Encoding

Download history 2585/week @ 2024-09-15 3975/week @ 2024-09-22 2955/week @ 2024-09-29 2191/week @ 2024-10-06 3441/week @ 2024-10-13 3196/week @ 2024-10-20 3581/week @ 2024-10-27 3662/week @ 2024-11-03 2470/week @ 2024-11-10 3645/week @ 2024-11-17 3574/week @ 2024-11-24 6569/week @ 2024-12-01 7749/week @ 2024-12-08 6039/week @ 2024-12-15 1314/week @ 2024-12-22 2159/week @ 2024-12-29

17,356 downloads per month
Used in 18 crates (3 directly)

Custom license

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

~125–355KB