Skip to main content

Module timer

Module timer 

Source
Expand description

Countdown timer widget.

Provides a Timer widget that renders remaining time, and a TimerState that counts down from a set duration with start/stop/reset semantics.

§Example

use ftui_widgets::timer::{Timer, TimerState};
use std::time::Duration;

let mut state = TimerState::new(Duration::from_secs(60));
assert_eq!(state.remaining(), Duration::from_secs(60));
assert!(!state.finished());

state.start();
state.tick(Duration::from_secs(1));
assert_eq!(state.remaining(), Duration::from_secs(59));

Re-exports§

pub use crate::stopwatch::StopwatchFormat as TimerFormat;

Structs§

Timer
A widget that displays remaining time from a TimerState.
TimerState
State for the countdown timer.