Instant structv0.1.0

Source
A reading of the monotonic clock.
pub struct Instant {
    // private fields
}

Copy. Meaningful only against another reading from the same process: there is no epoch and no calendar here, which is the point — nothing anybody does to the wall clock changes what Since answers.

Associated functions

Now

pub func Now() -> Instant

The clock, read now. Cannot fail on any supported system: the monotonic clock exists from boot and needs no permission.

Returns: the monotonic clock, read now

Source

Methods

Since

pub func Since(
    self: &Instant,
    earlier: Instant
) -> Duration?

The time between earlier and this reading, or None when earlier is not earlier. Refusing the reversed pair rather than answering with garbage is what makes a mixed-up argument order a visible bug instead of a wildly large duration.

NameTypeDescription
earlierInstantthe earlier reading

Returns: the time between the two readings, or None when earlier is not earlier

Source

Elapsed

pub func Elapsed(self: &Instant) -> Duration

The time from this reading to now.

Returns: the time from this reading to now

Source

Implements Debug

Instant conforms to Debug.

WriteDebug

pub func WriteDebug(
    self: &Instant,
    writer: &var TextWriter,
    spec: FormatSpec
) -> ! FormatError

Writes the reading as Instant(nanoseconds: N). The tick count is shown as it is held, in the unit it is held in, named and wrapped so it cannot be mistaken for a moment on any calendar. There is no Display counterpart: a monotonic reading has no text for a reader, only a difference from another reading, and that difference is a Duration. Reports whatever the writer reported, and UnsupportedRequest for any style or precision — a reading has one form, and neither a style nor a fraction has anything to select here.

NameTypeDescription
writer&var TextWriterthe destination
specFormatSpecwhat the placeholder asked for

Returns: success when the whole reading was accepted

Source