Skip to main content

encode_instant_to_duration

Function encode_instant_to_duration 

Source
pub fn encode_instant_to_duration(instant: Instant) -> Duration
Available on crate feature std only.
Expand description

Encodes an Instant into a Duration using a process-local baseline.

The mapping is exact for instants in the same process that are representable relative to that baseline. The baseline pairs a wall-clock duration with a monotonic instant once; wall-clock adjustments made afterwards do not change the mapping. Whether time advances while the machine sleeps inherits the platform behavior of Instant.

This encoding is not a durable deadline format. Values decoded in another process or after a restart are only wall-clock approximations.

ยงPanics

Panics if instant cannot be represented as a duration relative to the process-local baseline.