#nanosecond #duration #serialization #timestamp #nanos #serde

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

#519 in Encoding

Download history 72976/week @ 2025-09-20 73316/week @ 2025-09-27 69812/week @ 2025-10-04 75338/week @ 2025-10-11 72658/week @ 2025-10-18 79412/week @ 2025-10-25 75039/week @ 2025-11-01 84822/week @ 2025-11-08 91851/week @ 2025-11-15 83196/week @ 2025-11-22 80869/week @ 2025-11-29 470306/week @ 2025-12-06 937532/week @ 2025-12-13 519815/week @ 2025-12-20 427273/week @ 2025-12-27 961860/week @ 2026-01-03

2,993,509 downloads per month
Used in 192 crates (6 directly)

MIT/Apache

13KB
294 lines

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.


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,
}

Dependencies

~155–740KB
~14K SLoC