Struct tui_logger::Dispatcher

source ·
pub struct Dispatcher<E: Debug> { /* private fields */ }
Expand description

Dispatcher is used to dispatch any event to a dynamically built chain of handlers. The dispatch is a one-shot event. After an event is successfully processed, the dispatch chain is emptied.

extern crate tui_logger;
extern crate termion;

use tui_logger::Dispatcher;
use termion::event::{Event,Key};

let mut dispatcher = Dispatcher::new();
dispatcher.add_listener(|ev| { println!("called"); true });
dispatcher.dispatch(&Event::Key(Key::Up));

Implementations§

Create a new dispatcher

Add a listener at the end of the dispatch chain. Every Listener has to be a closure receiving a termion event as parameter and shall return a boolean.

Dispatches an event to the queue. The event is sent to the event handlers in the queue in FIFO order. If an event handler returns true, then the following event handlers will not be processed anymore, the queue will be emptied and the return value of dispatch() is true. If no event handler has returned true, or the event queue is empty, then the function returns false.

Clear the dispatcher queue

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.