Struct Mode

Source
pub struct Mode<'m, T: 'm> { /* private fields */ }
Expand description

Struct that manages collecting and combining ModeWrapper. This is the type supplied when submitting tasks in order to apply ModeWrappers.

Modes may be used by implementing the ModeWrapper trait to be able to wrap tasks in an enclosing function. Unlike Invokers, Modes and ModeWrappers are generic over the return type of the tasks they may wrap and thus can directly interact with the return value of the task. This also means that the lifetime of the Mode is tied to the lifetime of the type they are generic over.

Implementations§

Source§

impl<'m, T: 'm> Mode<'m, T>

Source

pub fn new() -> Self

Construct a new empty mode with no ModeCombiner.

This Mode may already be used to invoke tasks with, in which case the Mode will simply be ignored.

Source

pub fn with<M: ModeWrapper<'m, T> + 'm + Send + Sync>( self, mode_wrapper: M, ) -> Self

Add a new ModeWrapper implementation to this Mode.

This calls the ModeWrapper::into_combiner function of the ModeWrapper and sets the resulting ModeCombiner on this Mode and, if there already is ModeCombiner present, combines the two by calling ModeCombiner::combine on the existing ModeCombiner.

Trait Implementations§

Source§

impl<'m, T: 'm> Default for Mode<'m, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'m, T> Freeze for Mode<'m, T>

§

impl<'m, T> !RefUnwindSafe for Mode<'m, T>

§

impl<'m, T> Send for Mode<'m, T>

§

impl<'m, T> Sync for Mode<'m, T>

§

impl<'m, T> Unpin for Mode<'m, T>

§

impl<'m, T> !UnwindSafe for Mode<'m, T>

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.