EventResult

Enum EventResult 

Source
pub enum EventResult {
    Ignored,
    Consumed(Option<Callback>),
}
Expand description

Answer to an event notification. The event can be consumed or ignored.

Variants§

§

Ignored

The event was ignored. The parent can keep handling it.

§

Consumed(Option<Callback>)

The event was consumed. An optional callback to run is attached.

Implementations§

Source§

impl EventResult

Source

pub fn with_cb<F>(f: F) -> Self
where F: 'static + Fn(&mut Cursive) + Send + Sync,

Convenient method to create Consumed(Some(f))

Source

pub fn with_cb_once<F>(f: F) -> Self
where F: 'static + FnOnce(&mut Cursive) + Send,

Convenient method to create Consumed(Some(f))

After being called once, the callback will become a no-op.

Source

pub fn consumed() -> Self

Convenient method to create Consumed(None)

Source

pub fn is_consumed(&self) -> bool

Returns true if self is EventResult::Consumed.

Source

pub fn has_callback(&self) -> bool

Returns true if self contains a callback.

Source

pub fn process(self, s: &mut Cursive)

Process this result if it is a callback.

Does nothing otherwise.

Source

pub fn or_else<F>(self, f: F) -> Self
where F: FnOnce() -> EventResult,

Returns self if it is not EventResult::Ignored, otherwise returns f().

Source

pub fn and(self, other: Self) -> Self

Returns an event result that combines self and other.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> With for T

Source§

fn wrap_with<U, F: FnOnce(Self) -> U>(self, f: F) -> U

Calls the given closure and return the result. Read more
Source§

fn with<F: FnOnce(&mut Self)>(self, f: F) -> Self

Calls the given closure on self.
Source§

fn try_with<E, F>(self, f: F) -> Result<Self, E>
where F: FnOnce(&mut Self) -> Result<(), E>,

Calls the given closure on self.
Source§

fn with_if<F>(self, condition: bool, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure if condition == true.