Crate serde_humantime [] [src]

A crate providing Serde deserializers for Durations via the humantime crate.

Examples

You can use the deserialize function with the with or deserialize_with annotations:

extern crate serde_humantime;
extern crate serde;
#[macro_use]
extern crate serde_derive;

use std::time::Duration;

#[derive(Deserialize)]
struct Foo {
    #[serde(with = "serde_humantime")]
    timeout: Duration,
}

Or use the De wrapper type:

extern crate serde_humantime;
extern crate serde;
#[macro_use]
extern crate serde_derive;

use serde_humantime::De;
use std::time::Duration;

#[derive(Deserialize)]
struct Foo {
    timeout: De<Option<Duration>>,
}

Structs

De

A wrapper type which implements Deserialize for types involving Duration.

Functions

deserialize

Deserializes a Duration via the humantime crate.