pub struct TaskResult {
pub response: Option<String>,
pub next_action: NextAction,
pub task_id: String,
pub status_message: Option<String>,
}
Expand description
Result of a task execution.
Contains the response to send to the user and the next action to take.
The task_id
field is automatically set by the graph execution engine.
§Examples
use graph_flow::{TaskResult, NextAction};
// Basic task result
let result = TaskResult::new(
Some("Task completed successfully".to_string()),
NextAction::Continue
);
// Task result with status message
let result = TaskResult::new_with_status(
Some("Data validated".to_string()),
NextAction::Continue,
Some("All validation checks passed".to_string())
);
// Convenience methods
let result = TaskResult::move_to_next(); // Continue to next task
let result = TaskResult::move_to_next_direct(); // Continue and execute immediately
Fields§
§response: Option<String>
Response to send to the user
next_action: NextAction
Next action to take
task_id: String
ID of the task that generated this result
status_message: Option<String>
Optional status message that describes the current state of the task
Implementations§
Source§impl TaskResult
impl TaskResult
Sourcepub fn new(response: Option<String>, next_action: NextAction) -> Self
pub fn new(response: Option<String>, next_action: NextAction) -> Self
Create a new TaskResult with the given response and next action.
The task_id will be set automatically by the graph execution engine.
§Examples
use graph_flow::{TaskResult, NextAction};
let result = TaskResult::new(
Some("Hello, World!".to_string()),
NextAction::Continue
);
Sourcepub fn new_with_status(
response: Option<String>,
next_action: NextAction,
status_message: Option<String>,
) -> Self
pub fn new_with_status( response: Option<String>, next_action: NextAction, status_message: Option<String>, ) -> Self
Create a new TaskResult with response, next action, and status message.
The status message is used to describe the current state of the task. It’s only persisted in the context but not returned to the user. Specifically aimed at debugging and logging.
§Examples
use graph_flow::{TaskResult, NextAction};
let result = TaskResult::new_with_status(
Some("Data processed".to_string()),
NextAction::Continue,
Some("Processing completed with 95% confidence".to_string())
);
Sourcepub fn move_to_next() -> Self
pub fn move_to_next() -> Self
Create a TaskResult that moves to the next task (step-by-step execution).
This is a convenience method equivalent to:
TaskResult::new(None, NextAction::Continue);
Sourcepub fn move_to_next_direct() -> Self
pub fn move_to_next_direct() -> Self
Create a TaskResult that moves to the next task and executes it immediately.
This is a convenience method equivalent to:
TaskResult::new(None, NextAction::ContinueAndExecute);
Trait Implementations§
Source§impl Clone for TaskResult
impl Clone for TaskResult
Source§fn clone(&self) -> TaskResult
fn clone(&self) -> TaskResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TaskResult
impl Debug for TaskResult
Source§impl<'de> Deserialize<'de> for TaskResult
impl<'de> Deserialize<'de> for TaskResult
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>,
Auto Trait Implementations§
impl Freeze for TaskResult
impl RefUnwindSafe for TaskResult
impl Send for TaskResult
impl Sync for TaskResult
impl Unpin for TaskResult
impl UnwindSafe for TaskResult
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<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