[−][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());
Implementations
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.
Trait Implementations
impl From<Input> for InputChain
[src]
impl From<Option<Input>> for InputChain
[src]
Auto Trait Implementations
impl RefUnwindSafe for InputChain
impl Send for InputChain
impl Sync for InputChain
impl Unpin for InputChain
impl UnwindSafe for InputChain
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,