Skip to Content
VectorLib

Timer

vectorlib::Timer — fields, methods, parameters and return types.


pub struct Timer

A pausable countdown timer.

View source

Methods

Prop

Type

new

pub fn new(time: u32) -> Self

Construct a new timer. A timer is not paused when created.

  • time — how long to wait, in milliseconds

Parameters

Prop

Type

Returns

Self

View source

get_time_set

pub fn get_time_set(&mut self) -> u32

Get the amount of time the timer was set to wait.

Returns

u32

View source

get_time_left

pub fn get_time_left(&mut self) -> u32

Get the amount of time left on the timer (0 if done).

Returns

u32

View source

get_time_passed

pub fn get_time_passed(&mut self) -> u32

Get the amount of time passed on the timer.

Returns

u32

View source

is_done

pub fn is_done(&mut self) -> bool

Whether the timer is done.

Returns

bool

View source

is_paused

pub fn is_paused(&mut self) -> bool

Whether the timer is paused.

Faithful to LemLib: this accumulates elapsed time but does not update the last sample time, so calling it repeatedly on a running timer over-counts elapsed time.

Returns

bool

View source

set

pub fn set(&mut self, time: u32)

Set the amount of time the timer should wait. Also resets the timer.

Parameters

Prop

Type

Returns

()

View source

reset

pub fn reset(&mut self)

Reset the timer.

Returns

()

View source

pause

pub fn pause(&mut self)

Pause the timer.

Returns

()

View source

resume

pub fn resume(&mut self)

Resume the timer.

Returns

()

View source

wait_until_done

pub async fn wait_until_done(&mut self)

Block until the timer is done.

Returns

()

View source