PollEvents

Trait PollEvents 

Source
pub trait PollEvents<Event, Error>: Any
where Event: 'static, Error: 'static,
{ // Required methods fn as_any(&self) -> &dyn Any; fn poll(&mut self) -> Result<bool, Error>; fn read(&mut self) -> Result<Control<Event>, Error>; }
Expand description

Trait for an event-source.

If you need to add your own do the following:

  • Implement this trait for a struct that fits.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Source

fn poll(&mut self) -> Result<bool, Error>

Poll for a new event.

Events are not processed immediately when they occur. Instead, all event sources are polled, the poll state is put into a queue. Then the queue is emptied one by one and read_execute() is called.

This prevents issues with poll-ordering of multiple sources, and one source cannot just flood the app with events.

Source

fn read(&mut self) -> Result<Control<Event>, Error>

Read the event and distribute it.

If you add a new event, that doesn’t fit into AppEvents, you’ll have to define a new trait for your AppState and use that.

Implementors§

Source§

impl<Event, Error> PollEvents<Event, Error> for PollCrossterm
where Event: 'static + From<Event>, Error: 'static + From<Error>,

Source§

impl<Event, Error> PollEvents<Event, Error> for PollQuit
where Event: 'static + From<QuitEvent>, Error: 'static,

Source§

impl<Event, Error> PollEvents<Event, Error> for PollRendered
where Event: 'static + From<RenderedEvent>, Error: 'static + From<Error>,

Source§

impl<Event, Error> PollEvents<Event, Error> for PollTasks<Event, Error>
where Event: 'static + Send, Error: 'static + Send + From<TryRecvError>,

Source§

impl<Event, Error> PollEvents<Event, Error> for PollTimers
where Event: 'static + From<TimeOut>, Error: 'static + From<Error>,