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§
- Serde
- A wrapper type which implements
Serialize
andDeserialize
for types involvingSystemTime
andDuration
.
Functions§
- deserialize
- Deserializes a
Duration
orSystemTime
via the humantime crate. - serialize
- Serializes a
Duration
orSystemTime
via the humantime crate.