#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

#752 in Encoding

Download history 2627/week @ 2024-08-10 2339/week @ 2024-08-17 2671/week @ 2024-08-24 3610/week @ 2024-08-31 3032/week @ 2024-09-07 2708/week @ 2024-09-14 3928/week @ 2024-09-21 3032/week @ 2024-09-28 2178/week @ 2024-10-05 3405/week @ 2024-10-12 3169/week @ 2024-10-19 3545/week @ 2024-10-26 3793/week @ 2024-11-02 2470/week @ 2024-11-09 3594/week @ 2024-11-16 2987/week @ 2024-11-23

13,576 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–355KB