pub struct Timer<T> { /* private fields */ }
Expand description
A Timer event source
It generates events of type (T, TimerHandle<T>)
, providing you
an handle inside the event callback, allowing you to set new timeouts
as a response to a timeout being reached (for reccuring ticks for example).
Implementations
sourceimpl<T> Timer<T>
impl<T> Timer<T>
sourcepub fn new() -> Timer<T>
pub fn new() -> Timer<T>
Create a new timer with default parameters
Default time resolution is 100ms
sourcepub fn with_resolution(resolution: Duration) -> Timer<T>
pub fn with_resolution(resolution: Duration) -> Timer<T>
Create a new timer with a specific time resolution
sourcepub fn handle(&self) -> TimerHandle<T>
pub fn handle(&self) -> TimerHandle<T>
Get an handle for this timer
Trait Implementations
sourceimpl<T: 'static> EventSource for Timer<T>
impl<T: 'static> EventSource for Timer<T>
type Event = (T, TimerHandle<T>)
type Event = (T, TimerHandle<T>)
The type of events generated by your sources
sourcefn interest(&self) -> Ready
fn interest(&self) -> Ready
The interest value that will be given to
mio
when registering your sourcesourcefn pollopts(&self) -> PollOpt
fn pollopts(&self) -> PollOpt
The pollopt value that will be given to
mio
when registering your sourcesourcefn make_dispatcher<Data: 'static, F: FnMut((T, TimerHandle<T>), &mut Data) + 'static>(
&self,
callback: F
) -> Rc<RefCell<dyn EventDispatcher<Data>>>
fn make_dispatcher<Data: 'static, F: FnMut((T, TimerHandle<T>), &mut Data) + 'static>(
&self,
callback: F
) -> Rc<RefCell<dyn EventDispatcher<Data>>>
Wrap an user callback into a dispatcher, that will convert an
mio
readiness
into an event Read moreAuto Trait Implementations
impl<T> RefUnwindSafe for Timer<T>
impl<T> Send for Timer<T>where
T: Send,
impl<T> Sync for Timer<T>where
T: Send,
impl<T> Unpin for Timer<T>
impl<T> UnwindSafe for Timer<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more