Trait xidlehook_core::timers::Timer[][src]

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

    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 { ... } }

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

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

Return the time left based on the relative idle time

Loading content...

Provided methods

fn abort_urgency(&self) -> Option<Duration>[src]

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.

fn activate(&mut self) -> Result<()>[src]

Called when the timer was activated

fn abort(&mut self) -> Result<()>[src]

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

fn deactivate(&mut self) -> Result<()>[src]

Called when another timer was activated after this one

fn disabled(&mut self) -> bool[src]

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.

Loading content...

Implementors

impl Timer for CmdTimer[src]

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

Loading content...