Timer

Trait Timer 

Source
pub trait Timer {
    // Required method
    fn time_left(&mut self, idle_time: Duration) -> Result<Option<Duration>>;

    // Provided methods
    fn abort_urgency(&self) -> Option<Duration> { ... }
    fn activate(&mut self) -> Result<()> { ... }
    fn abort(&mut self) -> Result<()> { ... }
    fn deactivate(&mut self) -> Result<()> { ... }
    fn disabled(&mut self) -> bool { ... }
}
Expand description

The timer trait is used to tell xidlehook after how much idle time your timer should activate (relatively), and what activation actually means. It also provides you with the ability to implement what happens when the next timer is activated, and also to disable the timer.

Required Methods§

Source

fn time_left(&mut self, idle_time: Duration) -> Result<Option<Duration>>

Return the time left based on the relative idle time

Provided Methods§

Source

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

How urgent this timer wants to be notified on abort (when the user is no longer idle). Return as slow of a duration as you think is acceptable to be nice to the CPU - preferrably return None which basically means infinity.

Source

fn activate(&mut self) -> Result<()>

Called when the timer was activated

Source

fn abort(&mut self) -> Result<()>

Called when the timer was aborted early - such as when the user moves their mouse or otherwise stops being idle.

Source

fn deactivate(&mut self) -> Result<()>

Called when another timer was activated after this one

Source

fn disabled(&mut self) -> bool

Return true if the timer is disabled and should be skipped. Changes to this value are reflected - you may enable a timer that was previously disabled, and xidlehook will call it as soon as the timer is passed - or immediately if the timer has already passed.

Implementors§

Source§

impl Timer for CmdTimer

Source§

impl<F> Timer for CallbackTimer<F>
where F: FnMut(),