Skip to main content

TimerProps

Struct TimerProps 

Source
pub struct TimerProps {
Show 15 fields pub duration: Duration, pub mode: TimerMode, pub format: TimeFormat, pub color: Option<Color>, pub warn_color: Option<Color>, pub danger_color: Option<Color>, pub complete_color: Option<Color>, pub warn_threshold: Option<Duration>, pub danger_threshold: Option<Duration>, pub blink_on_danger: bool, pub blink_visible: bool, pub prefix: Option<String>, pub suffix: Option<String>, pub bold: bool, pub dim: bool,
}
Expand description

Properties for the Timer component.

Fields§

§duration: Duration

Current duration to display.

§mode: TimerMode

Timer mode (stopwatch or countdown).

§format: TimeFormat

Display format.

§color: Option<Color>

Default color.

§warn_color: Option<Color>

Color when warn threshold is reached (countdown only).

§danger_color: Option<Color>

Color when danger threshold is reached (countdown only).

§complete_color: Option<Color>

Color when completed (countdown reached zero).

§warn_threshold: Option<Duration>

Warn threshold (countdown only).

§danger_threshold: Option<Duration>

Danger threshold (countdown only).

§blink_on_danger: bool

Whether to show blinking when in danger zone.

§blink_visible: bool

Current blink state (for external control).

§prefix: Option<String>

Optional prefix text.

§suffix: Option<String>

Optional suffix text.

§bold: bool

Bold text.

§dim: bool

Dim text.

Implementations§

Source§

impl TimerProps

Source

pub fn stopwatch(elapsed: Duration) -> Self

Create a new stopwatch timer.

Source

pub fn countdown(remaining: Duration) -> Self

Create a new countdown timer.

Source

pub fn format(self, format: TimeFormat) -> Self

Set the display format.

Source

pub fn color(self, color: Color) -> Self

Set the default color.

Source

pub fn warn_at(self, threshold: Duration) -> Self

Set the warn threshold and color (countdown only).

Source

pub fn danger_at(self, threshold: Duration) -> Self

Set the danger threshold and color (countdown only).

Source

pub fn warn_color(self, color: Color) -> Self

Set the warn color.

Source

pub fn danger_color(self, color: Color) -> Self

Set the danger color.

Source

pub fn complete_color(self, color: Color) -> Self

Set the complete color.

Enable blinking when in danger zone.

Set current blink visibility state.

Source

pub fn prefix(self, text: impl Into<String>) -> Self

Set prefix text.

Source

pub fn suffix(self, text: impl Into<String>) -> Self

Set suffix text.

Source

pub fn bold(self) -> Self

Make text bold.

Source

pub fn dim(self) -> Self

Make text dim.

Source

pub fn is_warn(&self) -> bool

Check if timer is in warn zone.

Source

pub fn is_danger(&self) -> bool

Check if timer is in danger zone.

Source

pub fn is_complete(&self) -> bool

Check if countdown is complete.

Trait Implementations§

Source§

impl Clone for TimerProps

Source§

fn clone(&self) -> TimerProps

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TimerProps

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TimerProps

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.