pub struct Workflow<Context, A = DefaultAction, Output = ()>where
A: ActionType,{ /* private fields */ }Expand description
A workflow composed of connected nodes
Implementations§
Source§impl<Context, A, Output> Workflow<Context, A, Output>
impl<Context, A, Output> Workflow<Context, A, Output>
Sourcepub fn new<N>(start_node: N) -> Selfwhere
N: Node<Context, A, Output = Output> + 'static,
pub fn new<N>(start_node: N) -> Selfwhere
N: Node<Context, A, Output = Output> + 'static,
Create a new workflow with the given start node
Sourcepub fn add_node<N>(&mut self, node: N) -> &mut Selfwhere
N: Node<Context, A, Output = Output> + 'static,
pub fn add_node<N>(&mut self, node: N) -> &mut Selfwhere
N: Node<Context, A, Output = Output> + 'static,
Add a node to the workflow
Sourcepub fn connect(&mut self, from: &NodeId, action: A, to: &NodeId) -> &mut Self
pub fn connect(&mut self, from: &NodeId, action: A, to: &NodeId) -> &mut Self
Connect a node to another node with an action
Sourcepub fn set_default_route(&mut self, from: &NodeId, to: &NodeId) -> &mut Self
pub fn set_default_route(&mut self, from: &NodeId, to: &NodeId) -> &mut Self
Set a default route from one node to another (used when no specific action matches)
Sourcepub fn get_node(
&self,
id: NodeId,
) -> Option<&dyn Node<Context, A, Output = Output>>
pub fn get_node( &self, id: NodeId, ) -> Option<&dyn Node<Context, A, Output = Output>>
Get a node by its ID
Sourcepub async fn execute(&self, ctx: &mut Context) -> Result<Output, WorkflowError>
pub async fn execute(&self, ctx: &mut Context) -> Result<Output, WorkflowError>
Execute the workflow with the given context
Trait Implementations§
Auto Trait Implementations§
impl<Context, A, Output> Freeze for Workflow<Context, A, Output>
impl<Context, A = DefaultAction, Output = ()> !RefUnwindSafe for Workflow<Context, A, Output>
impl<Context, A, Output> Send for Workflow<Context, A, Output>
impl<Context, A, Output> Sync for Workflow<Context, A, Output>
impl<Context, A, Output> Unpin for Workflow<Context, A, Output>where
A: Unpin,
impl<Context, A = DefaultAction, Output = ()> !UnwindSafe for Workflow<Context, A, Output>
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