[−][src]Struct unsegen::input::InputChain
An intermediate element in a chain of Behavior
s that are matched against the event and
executed if applicable.
Examples:
use unsegen::input::*; let mut triggered_first = false; let mut triggered_second = false; let mut triggered_third = false; let input = Input { event: Event::Key(Key::Char('g')), raw: Vec::new(), //Incorrect, but does not matter for this example. }; let res = input .chain((Key::Char('f'), || triggered_first = true)) // does not match, passes event on .chain(|i: Input| if let Event::Key(Key::Char(_)) = i.event { triggered_second = true; None // matches! event will be consumed } else { Some(i) }) .chain((Key::Char('g'), || triggered_first = true)) // matches, but is not reached! .finish(); assert!(!triggered_first); assert!(triggered_second); assert!(!triggered_third); assert!(res.is_none());
Methods
impl InputChain
[src]
pub fn chain<B: Behavior>(self, behavior: B) -> InputChain
[src]
Add another behavior to the line of input processors that will try to consume the event one after another.
pub fn finish(self) -> Option<Input>
[src]
Unpack the final chain value. If the Input
was consumed by some Behavior
, the result
will be None, otherwise the original Input
will be returned.
Auto Trait Implementations
impl Send for InputChain
impl Sync for InputChain
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 = Infallible
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, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,