pub struct Graph {
pub id: String,
/* private fields */
}
Expand description
A graph of tasks that can be executed
Fields§
§id: String
Implementations§
Source§impl Graph
impl Graph
pub fn new(id: impl Into<String>) -> Self
Sourcepub fn set_task_timeout(&mut self, timeout: Duration)
pub fn set_task_timeout(&mut self, timeout: Duration)
Set the timeout duration for task execution
Sourcepub fn set_start_task(&self, task_id: impl Into<String>) -> &Self
pub fn set_start_task(&self, task_id: impl Into<String>) -> &Self
Set the starting task
Sourcepub fn add_edge(&self, from: impl Into<String>, to: impl Into<String>) -> &Self
pub fn add_edge(&self, from: impl Into<String>, to: impl Into<String>) -> &Self
Add an edge between tasks
Sourcepub fn add_conditional_edge<F>(
&self,
from: impl Into<String>,
condition: F,
yes: impl Into<String>,
no: impl Into<String>,
) -> &Self
pub fn add_conditional_edge<F>( &self, from: impl Into<String>, condition: F, yes: impl Into<String>, no: impl Into<String>, ) -> &Self
Add a conditional edge with an explicit else
branch.
yes
is taken when condition(ctx)
returns true
; otherwise no
is chosen.
Sourcepub async fn execute_session(
&self,
session: &mut Session,
) -> Result<ExecutionResult>
pub async fn execute_session( &self, session: &mut Session, ) -> Result<ExecutionResult>
Execute the graph with session management This method manages the session state and returns a simple status
Sourcepub async fn execute(
&self,
task_id: &str,
context: Context,
) -> Result<TaskResult>
pub async fn execute( &self, task_id: &str, context: Context, ) -> Result<TaskResult>
Execute the graph starting from a specific task
Sourcepub fn find_next_task(
&self,
current_task_id: &str,
context: &Context,
) -> Option<String>
pub fn find_next_task( &self, current_task_id: &str, context: &Context, ) -> Option<String>
Find the next task based on edges and conditions
Sourcepub fn start_task_id(&self) -> Option<String>
pub fn start_task_id(&self) -> Option<String>
Get the start task ID
Auto Trait Implementations§
impl !Freeze for Graph
impl !RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl !UnwindSafe for Graph
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
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>
Converts
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>
Converts
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