2 releases

0.1.1 Dec 4, 2024
0.1.0 Feb 17, 2024

#518 in Encoding

Download history 56/week @ 2024-09-04 57/week @ 2024-09-11 83/week @ 2024-09-18 191/week @ 2024-09-25 108/week @ 2024-10-02 128/week @ 2024-10-09 115/week @ 2024-10-16 94/week @ 2024-10-23 97/week @ 2024-10-30 103/week @ 2024-11-06 102/week @ 2024-11-13 95/week @ 2024-11-20 184/week @ 2024-11-27 497/week @ 2024-12-04 374/week @ 2024-12-11 293/week @ 2024-12-18

1,361 downloads per month

MIT/Apache

8KB
108 lines

byte-unit-serde

tests crates.io Documentation MIT/Apache-2 licensed

This crate provides de/serialization helper for byte-unit crate to use in combination with serde's with-annotation. This might be useful because it hides a byte-unit crate as an implementation details and allows use the simple u64 type instead. In other words, by using this crate, your code will not depend on the byte-unit crate.

Example

use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize)]
struct Foo {
    #[serde(with = "byte_unit_serde")]
    max_size: u64,
    /// This module also supports an optional values.
    #[serde(default, with = "byte_unit_serde")]
    min_size: Option<u64>,
}

The idea of this crate is heavily inspired by humantime-serde.

Dependencies

~1–1.7MB
~35K SLoC