Instant structv0.1.0
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
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.
| Name | Type | Description |
|---|---|---|
earlier | Instant | the earlier reading |
Returns: the time between the two readings, or None when earlier is not earlier
Elapsed
pub func Elapsed(self: &Instant) -> Duration
The time from this reading to now.
Returns: the time from this reading to now
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.
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
spec | FormatSpec | what the placeholder asked for |
Returns: success when the whole reading was accepted