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>
impl<'m, T: 'm> Mode<'m, T>
Sourcepub fn new() -> Self
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.
Sourcepub fn with<M: ModeWrapper<'m, T> + 'm + Send + Sync>(
self,
mode_wrapper: M,
) -> Self
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.