pub struct DependencyGraph { /* private fields */ }Expand description
Dependency graph for tracking file dependencies and computing build order.
Uses a directed acyclic graph (DAG) to represent file dependencies, where an edge from A to B means “A depends on B” (A includes B).
Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn file_count(&self) -> usize
pub fn file_count(&self) -> usize
Get the number of files in the graph.
Sourcepub fn contains_file(&self, path: &Path) -> bool
pub fn contains_file(&self, path: &Path) -> bool
Check if a file is in the graph.
Sourcepub fn add_file(&mut self, path: &Path)
pub fn add_file(&mut self, path: &Path)
Add a file to the graph.
If the file already exists, this is a no-op.
Sourcepub fn add_dependency(&mut self, from: &Path, to: &Path)
pub fn add_dependency(&mut self, from: &Path, to: &Path)
Add a dependency relationship: from depends on to.
Both files must already be added to the graph via add_file.
Sourcepub fn has_dependency(&self, from: &Path, to: &Path) -> bool
pub fn has_dependency(&self, from: &Path, to: &Path) -> bool
Check if there is a direct dependency from from to to.
Sourcepub fn topological_sort(&self) -> Result<Vec<PathBuf>>
pub fn topological_sort(&self) -> Result<Vec<PathBuf>>
Compute topological sort to determine build order.
Returns files in the order they should be transpiled (dependencies first). Returns an error if there are circular dependencies.
Sourcepub fn from_files(files: &[PathBuf]) -> Result<Self>
pub fn from_files(files: &[PathBuf]) -> Result<Self>
Build a dependency graph from a list of C files.
Parses #include directives to build the dependency graph.
Sourcepub fn parse_include_directives(code: &str) -> Vec<String>
pub fn parse_include_directives(code: &str) -> Vec<String>
Parse #include directives from C source code.
Returns a list of filenames (e.g., [“utils.h”, “stdio.h”]).
Sourcepub fn has_header_guard(path: &Path) -> Result<bool>
pub fn has_header_guard(path: &Path) -> Result<bool>
Check if a C header file has header guards (#ifndef/#define/#endif).
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