#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

#209 in Encoding

Download history 27658/week @ 2024-01-23 30602/week @ 2024-01-30 24914/week @ 2024-02-06 22692/week @ 2024-02-13 28701/week @ 2024-02-20 30659/week @ 2024-02-27 29335/week @ 2024-03-05 28307/week @ 2024-03-12 26425/week @ 2024-03-19 28213/week @ 2024-03-26 31697/week @ 2024-04-02 32746/week @ 2024-04-09 33444/week @ 2024-04-16 33363/week @ 2024-04-23 27055/week @ 2024-04-30 24957/week @ 2024-05-07

123,970 downloads per month
Used in 85 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