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>

source

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

source§

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>

Executes the undo action for this saga node, whatever that is.
source§

fn name(&self) -> ActionName

Return the name of the action used as the key in the ActionRegistry
source§

impl<ActionFuncType, UndoFuncType> Debug for ActionFunc<ActionFuncType, UndoFuncType>

source§

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

Formats the value using the given formatter. Read more

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.
source§

impl<T> SendSyncUnwindSafe for Twhere T: Send + Sync + UnwindSafe + ?Sized,