Crate humantime_serde[−][src]
Expand description
Serde support for the humantime
crate.
Based on this fork.
Currently std::time::{Duration, SystemTime}
are supported.
Example
use serde::{Serialize, Deserialize};
use std::time::{Duration, SystemTime};
#[derive(Serialize, Deserialize)]
struct Foo {
#[serde(with = "humantime_serde")]
timeout: Duration,
#[serde(default)]
#[serde(with = "humantime_serde")]
time: Option<SystemTime>,
}
Or use the Serde
wrapper type:
use serde::{Serialize, Deserialize};
use humantime_serde::Serde;
use std::time::SystemTime;
#[derive(Serialize, Deserialize)]
struct Foo {
timeout: Vec<Serde<SystemTime>>,
}
Modules
Reexport module.
Structs
A wrapper type which implements Serialize
and Deserialize
for
types involving SystemTime
and Duration
.
Functions
Deserializes a Duration
or SystemTime
via the humantime crate.
Serializes a Duration
or SystemTime
via the humantime crate.