pub struct ProjectScanner { /* private fields */ }Expand description
Scans a project directory for source files.
Respects .gitignore and .brrrignore patterns, supports filtering by language and extension, and optionally collects file metadata.
§Example
use go_brrr::callgraph::scanner::{ProjectScanner, ScanConfig};
let scanner = ProjectScanner::new("/path/to/project").unwrap();
// Scan all supported files
let files = scanner.scan_files().unwrap();
// Scan only Python files
let py_files = scanner.scan_language("python").unwrap();
// Advanced scanning with config
let config = ScanConfig::for_language("rust")
.with_excludes(&["**/target/**"])
.with_metadata();
let result = scanner.scan_with_config(&config).unwrap();Implementations§
Source§impl ProjectScanner
impl ProjectScanner
Sourcepub fn new(path: &str) -> Result<Self>
pub fn new(path: &str) -> Result<Self>
Create a new scanner for the given project root.
§Errors
Returns an error if the path does not exist or is not a directory.
Sourcepub fn scan_files(&self) -> Result<Vec<PathBuf>>
pub fn scan_files(&self) -> Result<Vec<PathBuf>>
Scan for all supported source files.
Returns file paths for all files with extensions recognized by the language registry. Respects .gitignore and .brrrignore.
Note: This method logs warnings for errors but continues scanning.
For full error details, use scan_files_with_errors() instead.
Sourcepub fn scan_files_with_errors(&self) -> Result<ScanResult>
pub fn scan_files_with_errors(&self) -> Result<ScanResult>
Scan for all supported source files with full error reporting.
Returns a ScanResult containing both the found files and any
errors encountered during scanning (permission denied, broken
symlinks, I/O errors, etc.).
§Example
use go_brrr::callgraph::scanner::ProjectScanner;
let scanner = ProjectScanner::new("/path/to/project").unwrap();
let result = scanner.scan_files_with_errors().unwrap();
println!("Found {} files", result.files.len());
if result.has_errors() {
eprintln!("Warning: {}", result.error_summary());
for error in &result.errors {
eprintln!(" - {}", error);
}
}Sourcepub fn scan_language(&self, lang_name: &str) -> Result<Vec<PathBuf>>
pub fn scan_language(&self, lang_name: &str) -> Result<Vec<PathBuf>>
Scan for files of a specific language.
§Arguments
lang_name- Language identifier (e.g., “python”, “typescript”, “rust”)
§Errors
Returns UnsupportedLanguage error if the language is not recognized.
Note: This method logs warnings for errors but continues scanning.
For full error details, use scan_language_with_errors() instead.
Sourcepub fn scan_language_with_errors(&self, lang_name: &str) -> Result<ScanResult>
pub fn scan_language_with_errors(&self, lang_name: &str) -> Result<ScanResult>
Scan for files of a specific language with full error reporting.
Returns a ScanResult containing both the found files and any
errors encountered during scanning.
§Arguments
lang_name- Language identifier (e.g., “python”, “typescript”, “rust”)
§Errors
Returns UnsupportedLanguage error if the language is not recognized.
Sourcepub fn scan_extensions(&self, extensions: &[&str]) -> Result<Vec<PathBuf>>
pub fn scan_extensions(&self, extensions: &[&str]) -> Result<Vec<PathBuf>>
Scan for files matching specific extensions.
§Arguments
extensions- File extensions to match (e.g., [“.py”, “.pyi”])
Note: This method logs warnings for errors but continues scanning.
For full error details, use scan_extensions_with_errors() instead.
Sourcepub fn scan_extensions_with_errors(
&self,
extensions: &[&str],
) -> Result<ScanResult>
pub fn scan_extensions_with_errors( &self, extensions: &[&str], ) -> Result<ScanResult>
Scan for files matching specific extensions with full error reporting.
Returns a ScanResult containing both the found files and any
errors encountered during scanning.
§Arguments
extensions- File extensions to match (e.g., [“.py”, “.pyi”])
Sourcepub fn scan_with_config(&self, config: &ScanConfig) -> Result<ScanResult>
pub fn scan_with_config(&self, config: &ScanConfig) -> Result<ScanResult>
Scan with full configuration options.
This is the most flexible scanning method, supporting:
- Language and extension filtering
- Include/exclude glob patterns
- Metadata collection
- Parallel processing for large projects
- Configurable error handling (fail-fast, collect-and-continue, log-only)
§Error Handling
By default, errors are collected and scanning continues (CollectAndContinue).
Use config.error_handling to change this behavior:
FailFast: Stop on first errorCollectAndContinue: Collect errors, continue scanning (default)LogOnly: Log warnings, don’t collect errors
§Memory Efficiency
This method uses single-pass filtering during directory traversal to avoid creating intermediate collections. For a 100K file project, this reduces memory usage by avoiding double-allocation of file entry vectors.
Sourcepub fn scan_with_metadata(&self) -> Result<Vec<FileMetadata>>
pub fn scan_with_metadata(&self) -> Result<Vec<FileMetadata>>
Scan and return detailed file metadata.
This is a convenience method equivalent to:
scanner.scan_with_config(&ScanConfig::default().with_metadata())Sourcepub fn scan_language_with_metadata(
&self,
lang_name: &str,
) -> Result<Vec<FileMetadata>>
pub fn scan_language_with_metadata( &self, lang_name: &str, ) -> Result<Vec<FileMetadata>>
Scan a specific language and return metadata.
Sourcepub fn estimate_file_count(&self) -> Result<usize>
pub fn estimate_file_count(&self) -> Result<usize>
Get the count of supported source files in the project.
Performs a full directory traversal to get an accurate count. Uses parallel walking for performance - on modern SSDs this completes in under 1 second for projects with up to 100K files.
This count matches what scan_files() will return (filtered by
supported languages, respecting .gitignore and .brrrignore).
Useful for progress bars or deciding scan strategy. Note: Errors during counting are logged but do not affect the count.
Auto Trait Implementations§
impl Freeze for ProjectScanner
impl RefUnwindSafe for ProjectScanner
impl Send for ProjectScanner
impl Sync for ProjectScanner
impl Unpin for ProjectScanner
impl UnwindSafe for ProjectScanner
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request