#duration #timestamp #nanosecond #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

#6 in #timestamp

Download history 25253/week @ 2024-06-20 23577/week @ 2024-06-27 18812/week @ 2024-07-04 23311/week @ 2024-07-11 24523/week @ 2024-07-18 26342/week @ 2024-07-25 26445/week @ 2024-08-01 30193/week @ 2024-08-08 31100/week @ 2024-08-15 32041/week @ 2024-08-22 28073/week @ 2024-08-29 32259/week @ 2024-09-05 31932/week @ 2024-09-12 33112/week @ 2024-09-19 38303/week @ 2024-09-26 27986/week @ 2024-10-03

136,861 downloads per month
Used in 96 crates (5 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