#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

#221 in Encoding

Download history 26594/week @ 2024-02-04 23462/week @ 2024-02-11 26170/week @ 2024-02-18 30462/week @ 2024-02-25 30531/week @ 2024-03-03 27509/week @ 2024-03-10 27024/week @ 2024-03-17 28730/week @ 2024-03-24 29590/week @ 2024-03-31 33520/week @ 2024-04-07 33225/week @ 2024-04-14 33516/week @ 2024-04-21 27613/week @ 2024-04-28 29591/week @ 2024-05-05 30717/week @ 2024-05-12 28607/week @ 2024-05-19

118,421 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