pub struct DependencyGraph { /* private fields */ }Expand description
Dependency graph for type compilation order
Tracks dependencies between types and provides topological sorting to determine the correct compilation order.
Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn add_dependency(&mut self, derived: TypeKey, base: TypeKey)
pub fn add_dependency(&mut self, derived: TypeKey, base: TypeKey)
Add a type dependency (derived_type depends on base_type)
This means base_type must be compiled before derived_type.
Sourcepub fn type_count(&self) -> usize
pub fn type_count(&self) -> usize
Get the number of types in the graph
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Get the number of dependency edges in the graph
Sourcepub fn has_dependencies(&self, type_key: TypeKey) -> bool
pub fn has_dependencies(&self, type_key: TypeKey) -> bool
Check if a type has any dependencies
Sourcepub fn get_dependencies(&self, type_key: TypeKey) -> &[TypeKey]
pub fn get_dependencies(&self, type_key: TypeKey) -> &[TypeKey]
Get the dependencies of a type
Sourcepub fn sort(&mut self) -> SchemaResult<()>
pub fn sort(&mut self) -> SchemaResult<()>
Perform topological sort and cycle detection using Kahn’s algorithm
After successful sorting, use compilation_order() to get types
in the order they should be compiled (dependencies first).
§Errors
Returns an error if a circular dependency is detected.
Sourcepub fn compilation_order(&self) -> &[TypeKey]
pub fn compilation_order(&self) -> &[TypeKey]
Get types in compilation order (dependencies first)
Must call sort() first or this will return an empty slice.