Expand description
Rust dependency extractor using tree-sitter AST traversal.
Extracts use declarations and pub use re-exports from Rust source files,
producing RustImportInfo and ExportInfo records for the dependency
graph. Supports:
- Simple imports:
use std::collections::HashMap; - Nested imports:
use std::collections::{HashMap, HashSet}; - Wildcard imports:
use module::*; - Aliased imports:
use std::io::Result as IoResult; - Crate-relative:
use crate::core::Engine; - Super-relative:
use super::utils; - Self-relative:
use self::types::Config; - Re-exports:
pub use types::Config;,pub(crate) use internal::Helper;
§Examples
ⓘ
use thread_flow::incremental::extractors::rust::RustDependencyExtractor;
use std::path::Path;
let extractor = RustDependencyExtractor::new();
let source = "use std::collections::HashMap;\nuse crate::config::Settings;";
let imports = extractor.extract_imports(source, Path::new("src/main.rs")).unwrap();
assert_eq!(imports.len(), 2);§Performance
Target: <5ms per file extraction. Tree-sitter parsing and AST traversal operate in a single pass without backtracking.
Structs§
- Export
Info - Information extracted from a Rust
pub usere-export. - Rust
Dependency Extractor - Extracts Rust import and export dependencies using tree-sitter AST traversal.
- Rust
Import Info - Information extracted from a single Rust
usedeclaration.
Enums§
- Extraction
Error - Errors that can occur during Rust dependency extraction.
- Visibility
- Visibility level of a Rust re-export (
pub use).