Available on crate features
serde
and serde-human-readable
only.Expand description
Use the well-known RFC 2822 format when serializing and deserializing a
FileTime
.
Use this module in combination with Serde’s with
attribute.
§Examples
use nt_time::{
FileTime,
serde::{Deserialize, Serialize},
serde_with::rfc_2822,
};
#[derive(Deserialize, Serialize)]
struct Time {
#[serde(with = "rfc_2822")]
time: FileTime,
}
let ft = Time {
time: FileTime::UNIX_EPOCH,
};
let json = serde_json::to_string(&ft).unwrap();
assert_eq!(json, r#"{"time":"Thu, 01 Jan 1970 00:00:00 +0000"}"#);
let ft: Time = serde_json::from_str(&json).unwrap();
assert_eq!(ft.time, FileTime::UNIX_EPOCH);
Modules§
- option
- Use the well-known RFC 2822 format when serializing and deserializing an
Option<FileTime>
.
Functions§
- deserialize
- Deserializes a
FileTime
from the given Serde deserializer. - serialize
- Serializes a
FileTime
into the given Serde serializer.