Crate humantime_serde
source ·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
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.