#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

#735 in Encoding

Download history 2987/week @ 2024-07-24 2924/week @ 2024-07-31 3208/week @ 2024-08-07 2272/week @ 2024-08-14 2110/week @ 2024-08-21 3728/week @ 2024-08-28 2842/week @ 2024-09-04 3330/week @ 2024-09-11 2485/week @ 2024-09-18 4047/week @ 2024-09-25 2593/week @ 2024-10-02 2565/week @ 2024-10-09 3449/week @ 2024-10-16 3364/week @ 2024-10-23 3459/week @ 2024-10-30 3477/week @ 2024-11-06

14,352 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

~130–360KB