pub struct TokioMain { /* private fields */ }
Expand description

An implementation of the pulse Mainloop trait that dispatches through tokio.

Implementations§

source§

impl TokioMain

source

pub fn new() -> Self

source

pub fn tick(&mut self, ctx: &mut Context<'_>) -> Poll<Option<Retval>>

Run callbacks and register wakers for the pulse mainloop.

This returns Ready if a callback was invoked, or Pending if everything is waiting on timers or I/O. The async run() or wait_for_ready() functions call this function internally.

source

pub async fn wait_for_ready(&mut self, ctx: &Context) -> Result<State, Retval>

Run the mainloop until the given context is either Ready or Failed/Terminated.

When initializing a single Context object, this can be simpler use than registering a state callback. You will need to call run on another task to actually use the context.

source

pub async fn run(&mut self) -> Retval

Run the mainloop until a quit is requested through the pulse API

Trait Implementations§

source§

impl Debug for TokioMain

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for TokioMain

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Mainloop for TokioMain

§

type MI = MainInner

Inner mainloop type.
source§

fn inner(&self) -> Rc<MainInner>

Get inner mainloop.
source§

fn new_io_event( &mut self, fd: i32, events: FlagSet, callback: Box<dyn FnMut(IoEventRef<Self::MI>, i32, FlagSet)> ) -> Option<IoEvent<Self::MI>>

Creates a new IO event. Read more
source§

fn new_timer_event( &mut self, tv: &UnixTs, callback: Box<dyn FnMut(TimeEventRef<Self::MI>)> ) -> Option<TimeEvent<Self::MI>>

Creates a new timer event. Read more
source§

fn new_timer_event_rt( &mut self, t: MonotonicTs, callback: Box<dyn FnMut(TimeEventRef<Self::MI>)> ) -> Option<TimeEvent<Self::MI>>

Creates a new monotonic-based timer event. Read more
source§

fn new_deferred_event( &mut self, callback: Box<dyn FnMut(DeferEventRef<Self::MI>)> ) -> Option<DeferEvent<Self::MI>>

Creates a new deferred event. Read more
source§

fn once_event(&mut self, callback: Box<dyn FnMut()>)

Runs the specified callback once from the main loop using an anonymous defer event. Read more
source§

fn quit(&mut self, retval: Retval)

Calls quit

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.