ProjectScanner

Struct ProjectScanner 

Source
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

Source

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.

Source

pub fn root(&self) -> &Path

Get the project root path.

Source

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.

Source

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);
    }
}
Source

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.

Source

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.

Source

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.

Source

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”])
Source

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 error
  • CollectAndContinue: 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.

Source

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())
Source

pub fn scan_language_with_metadata( &self, lang_name: &str, ) -> Result<Vec<FileMetadata>>

Scan a specific language and return metadata.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more