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

serde_nanos

Wrapper to process duration and timestamps as nanoseconds

5 releases

new 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 21346/week @ 2023-12-18 12056/week @ 2023-12-25 19229/week @ 2024-01-01 25926/week @ 2024-01-08 27802/week @ 2024-01-15 28853/week @ 2024-01-22 30428/week @ 2024-01-29 25765/week @ 2024-02-05 23567/week @ 2024-02-12 26118/week @ 2024-02-19 30287/week @ 2024-02-26 30525/week @ 2024-03-04 27871/week @ 2024-03-11 26545/week @ 2024-03-18 28918/week @ 2024-03-25 30182/week @ 2024-04-01

114,498 downloads per month
Used in 83 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–640KB
~12K SLoC