Trait WorkflowLike

Source
pub trait WorkflowLike:
    Send
    + Sync
    + Debug
    + 'static {
Show 13 methods // Required methods fn version(&self) -> u32; fn minor_version(&self) -> u32; fn reference(&self) -> &Reference; fn path(&self) -> &Path; fn get_row(&self, index: usize) -> Option<Rule>; fn get_rule(&self, identifier: &str) -> Option<Rule>; fn contains(&self, identifier: &str) -> bool; fn has_rule(&self, index: usize) -> bool; fn rule_count(&self) -> usize; fn rule_rows(&self) -> usize; fn iter_rows<'a>( &'a self, ) -> Box<dyn Iterator<Item = &'a Option<Rule>> + 'a>; fn iter_rules<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Rule> + 'a>; fn as_any(&self) -> &dyn Any;
}
Expand description

The central trait for interacting with workflow content.

This trait defines the interface for workflow management operations. It is designed to be thread-safe (Send + Sync) to support concurrent access in agentic workflow applications.

§Concurrency Guarantees

  • Send: The type can be safely sent (moved) to another thread
  • Sync: The type can be safely shared (&T) between threads
  • Arc<T> requires its contained type T to be Send + Sync

§Implementation Notes

The WorkflowLike trait provides both read-only and mutable operations, with the mutable operations typically implemented through interior mutability patterns to maintain thread safety.

§Examples

use aimx::{WorkflowLike, Workflow};
use std::sync::Arc;

// Create a workflow and wrap it in an Arc for thread-safe sharing
let workflow = Arc::new(Workflow::new());
 
// Multiple threads can safely read from the workflow
let workflow_clone = Arc::clone(&workflow);
std::thread::spawn(move || {
    println!("Workflow version: {}", workflow_clone.version());
});

Required Methods§

Source

fn version(&self) -> u32

Returns the major version (epoch) of the workflow.

The epoch represents major structural changes to the workflow. Increments when significant changes are made that require a new version.

Source

fn minor_version(&self) -> u32

Returns the minor version (partial) of the workflow.

The partial represents incremental updates within the same epoch. Increments for minor changes that don’t require a new major version.

Source

fn reference(&self) -> &Reference

Returns the reference identifier for this workflow.

The reference uniquely identifies the workflow within the workspace.

Source

fn path(&self) -> &Path

Returns the file system path to the workflow’s AIM file.

This path points to the .aim file that stores the workflow content.

Source

fn get_row(&self, index: usize) -> Option<Rule>

Retrieves a rule by its row index.

§Parameters
  • index: The zero-based row index
§Returns

Some(Rule) if the index is valid and contains a rule, None otherwise

Source

fn get_rule(&self, identifier: &str) -> Option<Rule>

Retrieves a rule by its identifier.

§Parameters
  • identifier: The rule’s unique identifier
§Returns

Some(Rule) if the identifier exists, None otherwise

Source

fn contains(&self, identifier: &str) -> bool

Checks if a rule with the given identifier exists.

§Parameters
  • identifier: The identifier to check
§Returns

true if the rule exists, false otherwise

Source

fn has_rule(&self, index: usize) -> bool

Checks if a specific row index contains a rule.

§Parameters
  • index: The row index to check
§Returns

true if the row contains a rule, false if empty or out of bounds

Source

fn rule_count(&self) -> usize

Returns the number of rules in the workflow.

This counts only the actual rules, excluding empty rows.

Source

fn rule_rows(&self) -> usize

Returns the total number of rows in the workflow.

This includes both rules and empty rows.

Source

fn iter_rows<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Option<Rule>> + 'a>

Returns an iterator over all rows.

The iterator yields &Option<Rule> items, including empty rows. Use this when you need to preserve the exact row structure.

Source

fn iter_rules<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Rule> + 'a>

Returns an iterator over all rules.

The iterator yields &Rule items, skipping empty rows. Use this when you only need the actual rules.

Source

fn as_any(&self) -> &dyn Any

Returns a reference to the workflow as a trait object.

This method enables downcasting to the concrete workflow type when working with trait objects.

Implementors§