Trait Timer

Source
pub trait Timer: 'static {
    // Required methods
    fn name(&self) -> &str;
    fn run(&self);

    // Provided methods
    fn run_before(&self) -> bool { ... }
    fn ended(&self) -> bool { ... }
    fn interval(&self) -> Option<Duration> { ... }
    fn start(self)
       where Self: Sized { ... }
}
Expand description

timer tasks

Required Methods§

Source

fn name(&self) -> &str

timer name

Source

fn run(&self)

timer run logic

Provided Methods§

Source

fn run_before(&self) -> bool

ren before, default return true
please execute the non blocking logic that ends immediately
do nothing when return false
execute Self::run in the thread pool when return true

Source

fn ended(&self) -> bool

the timer is ended
default is false

Source

fn interval(&self) -> Option<Duration>

task loop interval
if return None, will run continuously

Source

fn start(self)
where Self: Sized,

start timer

Implementors§

Source§

impl Timer for SimpleTimer

support timer