[][src]Struct ticktock::clock::Clock

pub struct Clock { /* fields omitted */ }

Clock structure.

Methods

impl Clock[src]

pub fn new(tick_len: Duration) -> Clock[src]

Creates a new clock.

Create a clock with a tick size of tick_len_ms, in ms.

pub fn new_with_start_time(tick_len: Duration, start: Instant) -> Clock[src]

Creates a new clock with a specified start time

pub fn framerate(fps: f64) -> Clock[src]

Creates a new fixed-framerate clock

pub fn framerate_with_start_time(fps: f64, start: Instant) -> Clock[src]

Creates a new fixed-framerate clock with a specified sart time

pub fn synced(&self, tick_len: Duration) -> Clock[src]

Creates a new clock with a different tick length that is synced to the original clock

pub fn started_at(&self) -> Instant[src]

Get start time

pub fn tick_num_at(&self, now: Instant) -> u128[src]

Returns the tick number preceding an specific instant in time

pub fn wait_until_tick(&self) -> (u128, Instant)[src]

Waits for the next clock tick.

Will wait until the next tick and return the current tick count.

Important traits for ClockIter<'a>
pub fn iter(&self) -> ClockIter[src]

Creates a clock iterator.

The iterator will iterate forever, calling wait_until_tick on each iteration. It will panic after about 293 years.

Returns (current tick number, absolute time) on each iteration, where absolute time is relative to a fixed offset that depends on the machine (see Instant).

Important traits for ClockIterRelative<'a>
pub fn rel_iter(&self) -> ClockIterRelative[src]

Create a relative clock iterator.

Similar to iter(), but the resulting iterator will return a tuple of (current tick number, relative time), with relative time being a time::Duration from the start of the clock.

Auto Trait Implementations

impl RefUnwindSafe for Clock

impl Send for Clock

impl Sync for Clock

impl Unpin for Clock

impl UnwindSafe for Clock

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.