pub enum Handled<T> {
    Matched(T),
    Unmatched,
}
Expand description

The reaction of an event handler to a particular event.

Handled describes whether or not a handler has matched a particular event. When matched, a handler may include an arbitrary output. When unmatched, there is no further output. Whether or not a handler has matched an event can affect the execution of a composite handler and the test harness.

Note that matching an event has no precise definition: handlers may react arbitrarily to events. In practice, there is little ambiguity, but handlers and adapters can match in particular ways to enable certain handler behaviors. See the until_first_match adapter for an example.

Variants§

§

Matched(T)

An event handler has matched and handled an event.

§

Unmatched

An event handler has not matched nor handled an event.

Implementations§

source§

impl<T> Handled<T>

source

pub fn map<U, F>(self, f: F) -> Handled<U>
where F: FnOnce(T) -> U,

source

pub fn and_then<U, F>(self, f: F) -> Handled<U>
where F: FnOnce(T) -> Handled<U>,

source

pub fn and<U>(self, right: Handled<U>) -> Handled<U>

source

pub fn try_and_then<U, F>(self, f: F) -> Handled<U>
where T: Try, F: FnOnce(T::Output) -> Handled<U>,

source

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

source

pub fn or(self, right: Self) -> Self

source

pub fn try_or_else<F>(self, f: F) -> Self
where T: Try, F: FnOnce() -> Self,

source

pub fn flatten(self) -> Handled<T::Output>
where T: Try,

source

pub fn matched(self) -> Option<T>

source

pub fn is_matched(&self) -> bool

source

pub fn is_unmatched(&self) -> bool

Trait Implementations§

source§

impl<T: Clone> Clone for Handled<T>

source§

fn clone(&self) -> Handled<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Handled<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> From<T> for Handled<T>

source§

fn from(matched: T) -> Self

Converts to this type from the input type.
source§

impl<T: PartialEq> PartialEq for Handled<T>

source§

fn eq(&self, other: &Handled<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Try for Handled<T>

§

type Output = T

§

type Residual = Handled<Infallible>

source§

fn from_output(output: Self::Output) -> Self

source§

fn from_residual(_: Self::Residual) -> Self

source§

fn branch(self) -> ControlFlow<Self::Residual, Self::Output>

source§

fn unwrap(self) -> Self::Output
where Self: Sized,

source§

fn expect(self, message: impl Display) -> Self::Output
where Self: Sized,

source§

impl<T: Copy> Copy for Handled<T>

source§

impl<T: Eq> Eq for Handled<T>

source§

impl<T> StructuralPartialEq for Handled<T>

Auto Trait Implementations§

§

impl<T> Freeze for Handled<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Handled<T>
where T: RefUnwindSafe,

§

impl<T> Send for Handled<T>
where T: Send,

§

impl<T> Sync for Handled<T>
where T: Sync,

§

impl<T> Unpin for Handled<T>
where T: Unpin,

§

impl<T> UnwindSafe for Handled<T>
where T: UnwindSafe,

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
§

impl<T> Encode<Ambiguous1> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T> Encode<Ambiguous2> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Cast the given object into a dyn std::any::Any.
source§

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

source§

const PRESENT: Presence<Self> = _

source§

const ABSENT: Presence<Self> = _

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<St> WithTag for St

§

fn tagged<T>(self, tag: T) -> Tagged<T, St>

Produce a new stream from this one which yields item tupled with a constant tag