2 releases
Uses old Rust 2015
0.1.1 | May 31, 2017 |
---|---|
0.1.0 | May 31, 2017 |
#35 in #deserializer
2,352 downloads per month
Used in 3 crates
7KB
83 lines
serde-humantime
A Serde deserializer for Duration
s using the humantime
crate.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
lib.rs
:
A crate providing Serde deserializers for Duration
s 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>>,
}
Dependencies
~190–425KB