Struct rubble::time::Instant [−][src]
pub struct Instant(_);
Expand description
A point in time, relative to an unspecfied epoch.
This has microsecond resolution and may wrap around after >1 hour. Apart from the wraparound, it is monotonic.
Instant
s are obtained from an implementation of Timer
. Instant
s created from different
Timer
instances (even when using the same implementation) are not compatible, and mixing
them in operations causes unspecified results. Duration
s are independent of the Timer
implementation and thus can be mixed freely.
Implementations
The maximum time between two Instant
s that can be handled by Instant::duration_since
.
This is defined to be a value of a few minutes, intended to be sufficient for the BLE stack.
Creates an Instant
from raw microseconds since an arbitrary implementation-defined
reference point.
This should only be called from a Timer
implementation.
Returns the raw value from which this Instant
was created.
This should only be called from a Timer
implementation.
Calculates the duration of time that has passed between earlier
and self
.
The maximum duration that can be calculated by this method is defined as MAX_TIME_BETWEEN
.
Calling this method when the Instant
s are further apart is an error and may panic. This is
done as a safeguard, since Instant
s can wrap around, which can cause the result of this
function to be incorrect. It does not prevent that from happening, but makes unexpected
durations show up much earlier.
Both self
and earlier
must have been created by the same Timer
, or the result of
this function will be unspecified.
Trait Implementations
A Duration
can be added to an Instant
, moving the Instant
forwards in time.
Performs the +=
operation. Read more
A Duration
can be subtracted from an Instant
, moving the Instant
backwards in time.
Instant
s can be subtracted, which computes the Duration
between the rhs and lhs using
Instant::duration_since
.