[][src]Struct rubble::time::Instant

pub struct 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.

Instants are obtained from an implementation of Timer. Instants created from different Timer instances (even when using the same implementation) are not compatible, and mixing them in operations causes unspecified results. Durations 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 Instants 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 Instants are further apart is an error and may panic. This is done as a safeguard, since Instants 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.

impl Sub<Instant> for Instant[src]

Instants 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.

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.

impl AddAssign<Duration> for Instant[src]

impl SubAssign<Duration> for Instant[src]

Subtracts a Duration from self.

impl Clone for Instant[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Instant

impl Sync for Instant

Blanket Implementations

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> From for T[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]