pub struct Scanner { /* private fields */ }Expand description
§Scanner: The Rock Star of our Show
BEHOLD! The Scanner itself! This is the main act. It takes the config,
the ignore lists, and a path, and it puts on a spectacular show of directory
traversal. It’s fast, it’s smart, and it knows all the best moves.
Implementations§
Source§impl Scanner
impl Scanner
Sourcepub fn quick_scan(&self) -> Result<(Vec<FileNode>, TreeStats)>
pub fn quick_scan(&self) -> Result<(Vec<FileNode>, TreeStats)>
Quick scan for basic project analysis - lighter weight than full scan Returns only basic stats and key files for faster integration
Sourcepub fn find_recent_files(&self, hours_ago: u64) -> Result<Vec<FileNode>>
pub fn find_recent_files(&self, hours_ago: u64) -> Result<Vec<FileNode>>
Find files modified within a specific time range Useful for finding recent activity in projects
Sourcepub fn find_key_files(&self) -> Result<Vec<FileNode>>
pub fn find_key_files(&self) -> Result<Vec<FileNode>>
Get key project files (build configs, main files, etc.) Returns a filtered list of important files for project analysis
Sourcepub fn new(root: &Path, config: ScannerConfig) -> Result<Self>
pub fn new(root: &Path, config: ScannerConfig) -> Result<Self>
§Scanner::new - Constructor
Creates a new Scanner instance. This involves:
- Storing the provided
configandrootpath. - Loading and compiling
.gitignorepatterns ifconfig.respect_gitignoreis true. - Compiling the
DEFAULT_IGNORE_PATTERNSifconfig.use_default_ignoresis true. - Initializing sets of system paths and specific files to always ignore.
This setup prepares the scanner for efficient should_ignore checks during traversal.
Sourcepub fn scan_stream(&self, sender: Sender<FileNode>) -> Result<TreeStats>
pub fn scan_stream(&self, sender: Sender<FileNode>) -> Result<TreeStats>
Stream nodes as they are discovered
This version of scan is optimized for the --stream flag.
It sends FileNode objects through the sender channel as soon as they are processed.
This allows the formatter to start displaying output immediately, which is great for large directories.
Returns the final TreeStats once the scan is complete.
Sourcepub fn scan(&self) -> Result<(Vec<FileNode>, TreeStats)>
pub fn scan(&self) -> Result<(Vec<FileNode>, TreeStats)>
§scan - The Full Scan (Non-Streaming)
Performs a complete directory scan, collecting all FileNodes that meet the criteria
(not ignored, or shown if ignored, and pass filters if any).
This method first traverses the entire directory structure defined by config.max_depth,
creating FileNode objects for each entry. It then performs a second pass if filters
are active to ensure that directories are only included if they (or their subdirectories)
contain files that match the filters.
Returns a tuple: (Vec<FileNode>, TreeStats).
§scan - The “Scan-It-All-Then-Sort-It-Out” Method
This is the classic way to scan. It’s a two-act show:
- Act I: Walk through every single file and directory, collecting a huge list of
FileNodes. - Act II: If there are filters, go through that huge list and pick out only the ones that match, making sure to keep their parent directories so the tree still makes sense. It’s thorough and great for when you need the whole picture before making decisions.
Auto Trait Implementations§
impl Freeze for Scanner
impl RefUnwindSafe for Scanner
impl Send for Scanner
impl Sync for Scanner
impl Unpin for Scanner
impl UnsafeUnpin for Scanner
impl UnwindSafe for Scanner
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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 more