Available on crate feature
serde
only.Expand description
Use Unix time in microseconds when serializing and deserializing a
FileTime
.
Use this module in combination with Serde’s with
attribute.
§Examples
use nt_time::{
serde::{Deserialize, Serialize},
serde_with::unix_time,
FileTime,
};
#[derive(Deserialize, Serialize)]
struct Time {
#[serde(with = "unix_time::microseconds")]
time: FileTime,
}
let ft = Time {
time: FileTime::NT_TIME_EPOCH,
};
let json = serde_json::to_string(&ft).unwrap();
assert_eq!(json, r#"{"time":-11644473600000000}"#);
let ft: Time = serde_json::from_str(&json).unwrap();
assert_eq!(ft.time, FileTime::NT_TIME_EPOCH);
Modules§
- Use Unix time in microseconds when serializing and deserializing an
Option<FileTime>
.