[][src]Struct climer::timer::Timer

pub struct Timer {
    pub state: TimerState,
    // some fields omitted
}

Fields

state: TimerState

Methods

impl Timer[src]

pub fn builder() -> TimerBuilder[src]

Returns a new TimerBuilder.

pub fn new(target_time: Option<Time>, output: Option<Output>) -> Self[src]

Create a new Timer with the given optional arguments: target_time (Time), and output (Output). If a target_time is given, then the timer will act more like a countdown. If no target_time is given, then the timer will act more like a stopwatch; it will never finish naturally, so instead you need to stop the timer when necessary.

pub fn set_target_time(&mut self, target_time: Time)[src]

Set a new target Time.

pub fn clear_target_time(&mut self)[src]

Removes the target Time. If the timer has no target time, then it acts like a stopwatch, endlessly counting upwards.

pub fn set_start_time(&mut self, start_time: Time)[src]

Set the starting time value. Used for starting the timer with a starting time other than 0.

pub fn clear_start_time(&mut self)[src]

Removes the start Time.

pub fn run(&mut self) -> ClimerResult[src]

Run the timer. This will lock the current thread until the time is up. If you want to update the timer yourself somewhere else, then don't call this method, instead call the update method to update the timer.

pub fn start(&mut self) -> ClimerResult[src]

Start the timer. Do not call this method directly if you are using the run method. Only call this method if you intend to update the timer manually by calling the update method. The start method can also be used as a restart.

pub fn stop(&mut self) -> ClimerResult[src]

Stops the timer, after it has been started using the start method.

pub fn pause(&mut self) -> ClimerResult[src]

Pauses the timer.

pub fn resume(&mut self) -> ClimerResult[src]

Resumes the timer from a paused state.

pub fn update(&mut self) -> ClimerResult[src]

Updates the timer. This will also attempt to write the remaining time to stdout or to a file, using the Output of this Timer.

pub fn print_output(&mut self) -> ClimerResult[src]

Print the current time to stdout or to a file using this timer's Output (if output exists).

pub fn time_output(&self) -> Time[src]

Returns a Time. If a target_time was given, then it returns the remaining time until the timer finishes; if no target_time was given, then it returns the time since the timer was started.

pub fn finish(&mut self) -> ClimerResult[src]

Finish the timer.

Trait Implementations

impl Clone for Timer[src]

impl Default for Timer[src]

Auto Trait Implementations

impl RefUnwindSafe for Timer

impl Send for Timer

impl Sync for Timer

impl Unpin for Timer

impl UnwindSafe for Timer

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.