[−][src]Struct rubble::time::Instant
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.
Methods
impl Instant
[src]
pub const MAX_TIME_BETWEEN: Duration
[src]
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.
pub fn from_raw_micros(micros: u32) -> Self
[src]
Creates an Instant
from raw microseconds since an arbitrary implementation-defined
reference point.
This should only be called from a Timer
implementation.
pub fn raw_micros(&self) -> u32
[src]
Returns the raw value from which this Instant
was created.
This should only be called from a Timer
implementation.
pub fn duration_since(&self, earlier: Instant) -> Duration
[src]
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
impl Copy for Instant
[src]
impl Display for Instant
[src]
impl Debug for Instant
[src]
impl Add<Duration> for Instant
[src]
A Duration
can be added to an Instant
, moving the Instant
forwards in time.
type Output = Self
The resulting type after applying the +
operator.
fn add(self, d: Duration) -> Self
[src]
impl Sub<Instant> for Instant
[src]
Instant
s can be subtracted, which computes the Duration
between the rhs and lhs using
Instant::duration_since
.
type Output = Duration
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Duration
[src]
impl Sub<Duration> for Instant
[src]
A Duration
can be subtracted from an Instant
, moving the Instant
backwards in time.
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, d: Duration) -> Self
[src]
impl AddAssign<Duration> for Instant
[src]
fn add_assign(&mut self, d: Duration)
[src]
impl SubAssign<Duration> for Instant
[src]
Subtracts a Duration
from self
.
fn sub_assign(&mut self, d: Duration)
[src]
impl Clone for Instant
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> From for T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,