[−][src]Struct tui_logger::Dispatcher
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));
Methods
impl<E> Dispatcher<E> where
E: Debug, [src]
E: Debug,
pub fn new() -> Dispatcher<E>[src]
Create a new dispatcher
pub fn add_listener<F: 'static + Fn(&E) -> bool>(&mut self, f: F)[src]
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.
pub fn dispatch(&mut self, ev: &E) -> bool[src]
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.
pub fn clear(&mut self)[src]
Clear the dispatcher queue
Auto Trait Implementations
impl<E> !Send for Dispatcher<E>
impl<E> !Sync for Dispatcher<E>
Blanket Implementations
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T> From for T[src]
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.