pub enum NextAction {
Continue,
ContinueAndExecute,
GoTo(String),
GoBack,
End,
WaitForInput,
}
Expand description
Defines what should happen after a task completes.
This enum controls the flow of execution in your workflow graph. Different variants provide different execution behaviors.
§Examples
use graph_flow::{NextAction, TaskResult};
// Step-by-step execution (pause after this task)
let result = TaskResult::new(
Some("Step 1 complete".to_string()),
NextAction::Continue
);
// Continuous execution (run next task immediately)
let result = TaskResult::new(
Some("Processing...".to_string()),
NextAction::ContinueAndExecute
);
// Wait for user input
let result = TaskResult::new(
Some("Please provide more information".to_string()),
NextAction::WaitForInput
);
// Jump to specific task
let result = TaskResult::new(
Some("Redirecting to error handler".to_string()),
NextAction::GoTo("error_handler".to_string())
);
// End the workflow
let result = TaskResult::new(
Some("Workflow completed!".to_string()),
NextAction::End
);
Variants§
Continue
Continue to the next task in the default path (step-by-step execution).
The workflow will pause after this task and wait for the next execution call. This gives you control over when the next task runs.
Best for: Interactive applications, web services, debugging
ContinueAndExecute
Continue to the next task and execute it immediately (continuous execution).
The workflow will automatically proceed to the next task without
pausing. This creates a recursive execution until the workflow
reaches End
, WaitForInput
, or an error.
Best for: Batch processing, automated workflows
GoTo(String)
Go to a specific task by ID.
Jump directly to the specified task, skipping the normal edge-based flow. Useful for error handling, loops, or dynamic routing.
§Examples
// Jump to error handler
let result = TaskResult::new(
Some("Error detected, routing to handler".to_string()),
NextAction::GoTo("error_handler".to_string())
);
// Create a retry loop
let result = TaskResult::new(
Some("Retrying...".to_string()),
NextAction::GoTo("validation_task".to_string())
);
GoBack
Go back to the previous task.
Note: This currently stays at the current task. Full back navigation logic may be implemented in future versions.
End
End the graph execution.
Terminates the workflow completely. No further tasks will be executed.
WaitForInput
Wait for user input before continuing.
Pauses the workflow and waits for external input. The workflow will stay at the current task until new data is provided and execution is resumed.
Best for: Human-in-the-loop workflows, interactive applications
Trait Implementations§
Source§impl Clone for NextAction
impl Clone for NextAction
Source§fn clone(&self) -> NextAction
fn clone(&self) -> NextAction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for NextAction
impl Debug for NextAction
Source§impl<'de> Deserialize<'de> for NextAction
impl<'de> Deserialize<'de> for NextAction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for NextAction
impl PartialEq for NextAction
Source§impl Serialize for NextAction
impl Serialize for NextAction
impl Eq for NextAction
impl StructuralPartialEq for NextAction
Auto Trait Implementations§
impl Freeze for NextAction
impl RefUnwindSafe for NextAction
impl Send for NextAction
impl Sync for NextAction
impl Unpin for NextAction
impl UnwindSafe for NextAction
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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>
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>
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