pub struct CallbackChain<T: Send + Sync + 'static> { /* private fields */ }Expand description
A named chain of callbacks for a lifecycle event.
Implementations§
Source§impl<T: Send + Sync + 'static> CallbackChain<T>
impl<T: Send + Sync + 'static> CallbackChain<T>
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Creates an empty callback chain for the given lifecycle name.
Sourcepub fn set_run_after_on_halt(&mut self, run_after_on_halt: bool)
pub fn set_run_after_on_halt(&mut self, run_after_on_halt: bool)
Controls whether after callbacks still run when the chain halts.
Sourcepub fn add(&mut self, callback: Callback<T>)
pub fn add(&mut self, callback: Callback<T>)
Adds a callback to the chain, replacing any existing callback with the same name.
Sourcepub fn run(&self, target: &mut T, action_name: &str) -> CallbackResult
pub fn run(&self, target: &mut T, action_name: &str) -> CallbackResult
Runs the callback chain without a custom action.
Sourcepub fn run_with<F>(
&self,
target: &mut T,
action_name: &str,
action: F,
) -> CallbackResult
pub fn run_with<F>( &self, target: &mut T, action_name: &str, action: F, ) -> CallbackResult
Runs the callback chain around the provided action.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for CallbackChain<T>
impl<T> !RefUnwindSafe for CallbackChain<T>
impl<T> Send for CallbackChain<T>
impl<T> Sync for CallbackChain<T>
impl<T> Unpin for CallbackChain<T>
impl<T> UnsafeUnpin for CallbackChain<T>
impl<T> !UnwindSafe for CallbackChain<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more