humantime_serde

Module option

Source
Expand description

Convenience module to allow serialization via humantime_serde for Option

§Example

use serde::{Serialize, Deserialize};
use std::time::{Duration, SystemTime};

#[derive(Serialize, Deserialize)]
struct Foo {
    #[serde(with = "humantime_serde::option")]
    timeout: Option<Duration>,
    #[serde(default)]
    #[serde(with = "humantime_serde::option")]
    time: Option<SystemTime>,
}

Functions§

  • Deserialize an Option<Duration> or Option<SystemTime>
  • Serializes an Option<Duration> or Option<SystemTime>