Struct steno::ActionFunc
source · pub struct ActionFunc<ActionFuncType, UndoFuncType> { /* private fields */ }
Expand description
Implementation of Action
that uses ordinary functions for the action and
undo action
Implementations§
source§impl<ActionFuncType, UndoFuncType> ActionFunc<ActionFuncType, UndoFuncType>
impl<ActionFuncType, UndoFuncType> ActionFunc<ActionFuncType, UndoFuncType>
sourcepub fn new_action<Name, UserType, ActionFuncOutput>(
name: Name,
action_func: ActionFuncType,
undo_func: UndoFuncType
) -> Arc<dyn Action<UserType>>where
Name: AsRef<str>,
UserType: SagaType,
for<'c> ActionFuncType: ActionFn<'c, UserType, Output = ActionFuncResult<ActionFuncOutput, ActionError>>,
ActionFuncOutput: ActionData,
for<'c> UndoFuncType: ActionFn<'c, UserType, Output = UndoResult>,
pub fn new_action<Name, UserType, ActionFuncOutput>( name: Name, action_func: ActionFuncType, undo_func: UndoFuncType ) -> Arc<dyn Action<UserType>>where Name: AsRef<str>, UserType: SagaType, for<'c> ActionFuncType: ActionFn<'c, UserType, Output = ActionFuncResult<ActionFuncOutput, ActionError>>, ActionFuncOutput: ActionData, for<'c> UndoFuncType: ActionFn<'c, UserType, Output = UndoResult>,
Construct an Action
from a pair of functions, using action_func
for the action and undo_func
for the undo action
The result is returned as Arc<dyn Action>
so that it can be used
directly where Action
s are expected. (The struct ActionFunc
has no
interfaces of its own so there’s generally no need to have the specific
type.)
Trait Implementations§
source§impl<UserType, ActionFuncType, ActionFuncOutput, UndoFuncType> Action<UserType> for ActionFunc<ActionFuncType, UndoFuncType>where
UserType: SagaType,
for<'c> ActionFuncType: ActionFn<'c, UserType, Output = ActionFuncResult<ActionFuncOutput, ActionError>>,
ActionFuncOutput: ActionData,
for<'c> UndoFuncType: ActionFn<'c, UserType, Output = UndoResult>,
impl<UserType, ActionFuncType, ActionFuncOutput, UndoFuncType> Action<UserType> for ActionFunc<ActionFuncType, UndoFuncType>where UserType: SagaType, for<'c> ActionFuncType: ActionFn<'c, UserType, Output = ActionFuncResult<ActionFuncOutput, ActionError>>, ActionFuncOutput: ActionData, for<'c> UndoFuncType: ActionFn<'c, UserType, Output = UndoResult>,
source§fn do_it(&self, sgctx: ActionContext<UserType>) -> BoxFuture<'_, ActionResult>
fn do_it(&self, sgctx: ActionContext<UserType>) -> BoxFuture<'_, ActionResult>
Executes the action for this saga node, whatever that is. Actions
function like requests in distributed sagas: critically, they must be
idempotent. This means that multiple calls to the action have the
same result on the system as a single call, although the action is not
necessarily required to return the same result. Read more
source§fn undo_it(&self, sgctx: ActionContext<UserType>) -> BoxFuture<'_, UndoResult>
fn undo_it(&self, sgctx: ActionContext<UserType>) -> BoxFuture<'_, UndoResult>
Executes the undo action for this saga node, whatever that is.
source§fn name(&self) -> ActionName
fn name(&self) -> ActionName
Return the name of the action used as the key in the ActionRegistry
Auto Trait Implementations§
impl<ActionFuncType, UndoFuncType> RefUnwindSafe for ActionFunc<ActionFuncType, UndoFuncType>where ActionFuncType: RefUnwindSafe, UndoFuncType: RefUnwindSafe,
impl<ActionFuncType, UndoFuncType> Send for ActionFunc<ActionFuncType, UndoFuncType>where ActionFuncType: Send, UndoFuncType: Send,
impl<ActionFuncType, UndoFuncType> Sync for ActionFunc<ActionFuncType, UndoFuncType>where ActionFuncType: Sync, UndoFuncType: Sync,
impl<ActionFuncType, UndoFuncType> Unpin for ActionFunc<ActionFuncType, UndoFuncType>where ActionFuncType: Unpin, UndoFuncType: Unpin,
impl<ActionFuncType, UndoFuncType> UnwindSafe for ActionFunc<ActionFuncType, UndoFuncType>where ActionFuncType: UnwindSafe, UndoFuncType: UnwindSafe,
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