pub struct RefGraph { /* private fields */ }Expand description
A reference graph built from an AgentScript AST.
The graph represents relationships between definitions (topics, actions, variables) and can be used for validation, analysis, and querying.
Implementations§
Source§impl RefGraph
impl RefGraph
Sourcepub fn find_usages(&self, target: NodeIndex) -> QueryResult
pub fn find_usages(&self, target: NodeIndex) -> QueryResult
Find all nodes that use (reference) the given node.
This returns nodes that have outgoing edges pointing to the target.
Sourcepub fn find_dependencies(&self, source: NodeIndex) -> QueryResult
pub fn find_dependencies(&self, source: NodeIndex) -> QueryResult
Find all nodes that the given node depends on.
This returns nodes that the source has outgoing edges pointing to.
Sourcepub fn find_incoming_transitions(&self, topic: NodeIndex) -> QueryResult
pub fn find_incoming_transitions(&self, topic: NodeIndex) -> QueryResult
Find all topics that transition to the given topic.
Sourcepub fn find_outgoing_transitions(&self, topic: NodeIndex) -> QueryResult
pub fn find_outgoing_transitions(&self, topic: NodeIndex) -> QueryResult
Find all topics that the given topic transitions to.
Sourcepub fn find_action_invokers(&self, action_def: NodeIndex) -> QueryResult
pub fn find_action_invokers(&self, action_def: NodeIndex) -> QueryResult
Find all reasoning actions that invoke the given action definition.
Sourcepub fn find_variable_readers(&self, variable: NodeIndex) -> QueryResult
pub fn find_variable_readers(&self, variable: NodeIndex) -> QueryResult
Find all actions that read the given variable.
Sourcepub fn find_variable_writers(&self, variable: NodeIndex) -> QueryResult
pub fn find_variable_writers(&self, variable: NodeIndex) -> QueryResult
Find all actions that write to the given variable.
Sourcepub fn topic_execution_order(&self) -> Option<Vec<NodeIndex>>
pub fn topic_execution_order(&self) -> Option<Vec<NodeIndex>>
Get a topological ordering of topics (for execution order).
Returns None if there are cycles.
Sourcepub fn get_topic_reasoning_actions(&self, topic_name: &str) -> Vec<NodeIndex>
pub fn get_topic_reasoning_actions(&self, topic_name: &str) -> Vec<NodeIndex>
Get all reasoning actions in a topic.
Sourcepub fn get_topic_action_defs(&self, topic_name: &str) -> Vec<NodeIndex>
pub fn get_topic_action_defs(&self, topic_name: &str) -> Vec<NodeIndex>
Get all action definitions in a topic.
Source§impl RefGraph
impl RefGraph
Sourcepub fn validate(&self) -> ValidationResult
pub fn validate(&self) -> ValidationResult
Perform full validation of the reference graph.
Returns errors for issues that would cause runtime failures, and warnings for issues that may indicate problems.
Sourcepub fn find_cycles(&self) -> Vec<ValidationError>
pub fn find_cycles(&self) -> Vec<ValidationError>
Find cycles in topic transitions.
Topic transitions should form a DAG. Cycles indicate infinite loops.
Sourcepub fn find_unreachable_topics(&self) -> Vec<ValidationError>
pub fn find_unreachable_topics(&self) -> Vec<ValidationError>
Find topics that are unreachable from start_agent.
Sourcepub fn find_unused_actions(&self) -> Vec<ValidationError>
pub fn find_unused_actions(&self) -> Vec<ValidationError>
Find action definitions that are never invoked.
Sourcepub fn find_unused_variables(&self) -> Vec<ValidationError>
pub fn find_unused_variables(&self) -> Vec<ValidationError>
Find variables that are never read.
Source§impl RefGraph
impl RefGraph
Sourcepub fn from_ast(ast: &AgentFile) -> Result<Self, GraphBuildError>
pub fn from_ast(ast: &AgentFile) -> Result<Self, GraphBuildError>
Build a reference graph from a parsed AgentScript AST.
This traverses the AST and builds nodes for all definitions, then creates edges for all references between them.
Sourcepub fn inner(&self) -> &DiGraph<RefNode, RefEdge>
pub fn inner(&self) -> &DiGraph<RefNode, RefEdge>
Get the underlying petgraph for advanced operations.
Sourcepub fn get_action_def(&self, topic: &str, action: &str) -> Option<NodeIndex>
pub fn get_action_def(&self, topic: &str, action: &str) -> Option<NodeIndex>
Look up an action definition node by topic and action name.
Sourcepub fn get_reasoning_action(
&self,
topic: &str,
action: &str,
) -> Option<NodeIndex>
pub fn get_reasoning_action( &self, topic: &str, action: &str, ) -> Option<NodeIndex>
Look up a reasoning action node by topic and action name.
Sourcepub fn get_variable(&self, name: &str) -> Option<NodeIndex>
pub fn get_variable(&self, name: &str) -> Option<NodeIndex>
Look up a variable node by name.
Sourcepub fn get_start_agent(&self) -> Option<NodeIndex>
pub fn get_start_agent(&self) -> Option<NodeIndex>
Get the start_agent node index.
Sourcepub fn topic_names(&self) -> impl Iterator<Item = &str>
pub fn topic_names(&self) -> impl Iterator<Item = &str>
Get all topic names in the graph.
Sourcepub fn variable_names(&self) -> impl Iterator<Item = &str>
pub fn variable_names(&self) -> impl Iterator<Item = &str>
Get all variable names in the graph.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the number of nodes in the graph.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Get the number of edges in the graph.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RefGraph
impl RefUnwindSafe for RefGraph
impl Send for RefGraph
impl Sync for RefGraph
impl Unpin for RefGraph
impl UnsafeUnpin for RefGraph
impl UnwindSafe for RefGraph
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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.