#nanosecond #serialization #duration #json #serde #timestamp #serde-json

serde_nanos

Wrapper to process duration and timestamps as nanoseconds

5 releases

0.1.4 Apr 4, 2024
0.1.3 Feb 20, 2023
0.1.2 Jan 28, 2022
0.1.1 Dec 1, 2021
0.1.0 Dec 1, 2021

#216 in Encoding

Download history 27921/week @ 2024-02-02 23363/week @ 2024-02-09 24389/week @ 2024-02-16 31277/week @ 2024-02-23 29857/week @ 2024-03-01 28528/week @ 2024-03-08 27486/week @ 2024-03-15 29029/week @ 2024-03-22 28019/week @ 2024-03-29 31688/week @ 2024-04-05 35097/week @ 2024-04-12 32373/week @ 2024-04-19 30258/week @ 2024-04-26 28319/week @ 2024-05-03 30350/week @ 2024-05-10 24169/week @ 2024-05-17

119,292 downloads per month
Used in 81 crates (4 directly)

MIT/Apache

13KB
294 lines

A serde wrapper that can be used to serialize durations as nanoseconds. It's often useful together with serde_json to communicate with JSON protocols.

Example

use std::time::Duration;

pub struct Message {
    #[serde(with = "serde_nanos")]
    expires_in: Duration,
}

lib.rs:

Serde Nanos

Documentation | Github | Crate

A serde wrapper that can be used to serialize timestamps and durations as nanoseconds.

It's often useful together with serde_json to communicate with JSON protocols.

Dependencies

~110–630KB
~12K SLoC