Skip to main content

ConsumedEvent

Trait ConsumedEvent 

Source
pub trait ConsumedEvent {
    // Required method
    fn is_consumed(&self) -> bool;

    // Provided methods
    fn or_else<F>(self, f: F) -> Self
       where F: FnOnce() -> Self,
             Self: Sized { ... }
    fn or_else_try<F, E>(self, f: F) -> Result<Self, E>
       where Self: Sized,
             F: FnOnce() -> Result<Self, E> { ... }
    fn and_then<F>(self, f: F) -> Self
       where Self: Sized + Ord,
             F: FnOnce() -> Self { ... }
    fn and_then_try<F, E>(self, f: F) -> Result<Self, E>
       where Self: Sized + Ord,
             F: FnOnce() -> Result<Self, E> { ... }
    fn and<F>(self, f: F) -> Self
       where Self: Sized + Ord,
             F: FnOnce() -> Self { ... }
    fn and_try<F, E>(self, f: F) -> Result<Self, E>
       where Self: Sized + Ord,
             F: FnOnce() -> Result<Self, E> { ... }
}
Expand description

When calling multiple event-handlers, the minimum information required from the result is ‘has consumed/didn’t consume’ the event.

The event-handler may also react to the event and not call it ‘consuming the event’. But this is tricky, non-obvious and frowned upon. The caller may also just ignore the fact.

See also flow and try_flow and the extra break_flow.

Required Methods§

Source

fn is_consumed(&self) -> bool

Is this the ‘consumed’ result.

Provided Methods§

Source

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

Or-Else chaining with is_consumed() as the split.

Source

fn or_else_try<F, E>(self, f: F) -> Result<Self, E>
where Self: Sized, F: FnOnce() -> Result<Self, E>,

Or-Else chaining with is_consumed() as the split.

Source

fn and_then<F>(self, f: F) -> Self
where Self: Sized + Ord, F: FnOnce() -> Self,

And_then-chaining based on is_consumed(). Returns max(self, f()).

Source

fn and_then_try<F, E>(self, f: F) -> Result<Self, E>
where Self: Sized + Ord, F: FnOnce() -> Result<Self, E>,

And_then-chaining based on is_consumed(). Returns max(self, f()).

Source

fn and<F>(self, f: F) -> Self
where Self: Sized + Ord, F: FnOnce() -> Self,

👎Deprecated since 1.2.2:

use and_then()

Then-chaining. Returns max(self, f()).

Source

fn and_try<F, E>(self, f: F) -> Result<Self, E>
where Self: Sized + Ord, F: FnOnce() -> Result<Self, E>,

👎Deprecated since 1.2.2:

use and_then_try()

Then-chaining. Returns max(self, f()).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ConsumedEvent for PopupOutcome

Source§

impl<V, E> ConsumedEvent for Result<V, E>
where V: ConsumedEvent,

Implementors§