Skip to main content

Module serde_time

Module serde_time 

Source
Expand description

Times and spans on the wire, and in what the SDK keeps on disk, as one integer each, so every client language reads them without serde’s {secs, nanos} struct: #[serde(with = "serde_time::unix_seconds")] on a SystemTime, serde_time::millis on a Duration, and each one’s option on an Option. A field keeps its old wire name with rename (position_ms), so the wire and the stores do not change.

An Option comes two ways, and the module says which: option_required for a field the wire must carry (null for none), option for one read as none when left out. Serde cannot give a with field a default, so option goes with #[serde(default)]; a test here finds any option field in the workspace without it.

A time this platform cannot hold is refused when read, never a panic: on wasm32 (the web UI) a SystemTime cannot go before the epoch, so a peer’s -1 is a decode error there.

Modules§

millis
A span as whole milliseconds.
unix_millis
A point in time as whole milliseconds since the Unix epoch.
unix_seconds
A point in time as whole seconds since the Unix epoch.

Functions§

epoch
The Unix epoch, for #[serde(default = "...")] on a SystemTime (which has no Default): older than any time kept.