#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

#214 in Encoding

Download history 27037/week @ 2024-03-16 28604/week @ 2024-03-23 29456/week @ 2024-03-30 32856/week @ 2024-04-06 34426/week @ 2024-04-13 32646/week @ 2024-04-20 28157/week @ 2024-04-27 29471/week @ 2024-05-04 30443/week @ 2024-05-11 30065/week @ 2024-05-18 24745/week @ 2024-05-25 26785/week @ 2024-06-01 27796/week @ 2024-06-08 24273/week @ 2024-06-15 24774/week @ 2024-06-22 11058/week @ 2024-06-29

92,534 downloads per month
Used in 88 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–640KB
~12K SLoC