2 releases

0.1.1 Dec 4, 2024
0.1.0 Feb 17, 2024

#462 in Encoding

Download history 77/week @ 2024-11-14 124/week @ 2024-11-21 255/week @ 2024-11-28 456/week @ 2024-12-05 369/week @ 2024-12-12 254/week @ 2024-12-19 185/week @ 2024-12-26 369/week @ 2025-01-02 591/week @ 2025-01-09 403/week @ 2025-01-16 340/week @ 2025-01-23 276/week @ 2025-01-30 261/week @ 2025-02-06 280/week @ 2025-02-13 176/week @ 2025-02-20 265/week @ 2025-02-27

1,027 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