pub struct DependencyGraph { /* private fields */ }Expand description
Dependency graph for managing step execution order.
Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn new(steps: Vec<DependentStep>) -> Result<DependencyGraph, String>
pub fn new(steps: Vec<DependentStep>) -> Result<DependencyGraph, String>
Create a new dependency graph from a list of steps.
Validates the graph for cycles and missing dependencies.
Sourcepub fn ready_steps(&self) -> Vec<&DependentStep>
pub fn ready_steps(&self) -> Vec<&DependentStep>
Get all steps that are currently ready to execute.
Sourcepub fn ready_step_ids(&self) -> Vec<&str>
pub fn ready_step_ids(&self) -> Vec<&str>
Get the IDs of ready steps.
Sourcepub fn has_ready_steps(&self) -> bool
pub fn has_ready_steps(&self) -> bool
Check if there are any steps ready to execute.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if all steps are complete.
Sourcepub fn has_failed(&self) -> bool
pub fn has_failed(&self) -> bool
Check if any step has failed.
Sourcepub fn take_ready_step(&mut self) -> Option<&DependentStep>
pub fn take_ready_step(&mut self) -> Option<&DependentStep>
Take the next ready step for execution.
Returns None if no steps are ready.
Sourcepub fn take_ready_steps(&mut self, max: usize) -> Vec<String>
pub fn take_ready_steps(&mut self, max: usize) -> Vec<String>
Take multiple ready steps for parallel execution.
Returns up to max steps that are ready and parallel-safe together.
Sourcepub fn complete(&mut self, step_id: &str, result: StepResult)
pub fn complete(&mut self, step_id: &str, result: StepResult)
Mark a step as complete and update the graph.
This removes the step from dependencies of waiting steps, potentially making them ready.
Sourcepub fn execution_order(&self) -> Vec<String>
pub fn execution_order(&self) -> Vec<String>
Get topological sort order of steps.
Returns step IDs in an order where dependencies come before dependents.
Sourcepub fn max_parallelism(&self) -> usize
pub fn max_parallelism(&self) -> usize
Calculate the maximum parallelism possible in this graph.
This is the maximum number of steps that could run concurrently in an ideal execution.
Sourcepub fn get_step(&self, id: &str) -> Option<&DependentStep>
pub fn get_step(&self, id: &str) -> Option<&DependentStep>
Get a step by ID.
Sourcepub fn get_result(&self, id: &str) -> Option<&StepResult>
pub fn get_result(&self, id: &str) -> Option<&StepResult>
Get the result for a step.
Sourcepub fn results(&self) -> &HashMap<String, StepResult>
pub fn results(&self) -> &HashMap<String, StepResult>
Get all results.
Sourcepub fn step_count(&self) -> usize
pub fn step_count(&self) -> usize
Get count of steps.
Sourcepub fn completed_count(&self) -> usize
pub fn completed_count(&self) -> usize
Get count of completed steps.
Sourcepub fn failed_count(&self) -> usize
pub fn failed_count(&self) -> usize
Get count of failed steps.
Trait Implementations§
Source§impl Clone for DependencyGraph
impl Clone for DependencyGraph
Source§fn clone(&self) -> DependencyGraph
fn clone(&self) -> DependencyGraph
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more