Skip to main content

ScanConfig

Struct ScanConfig 

Source
#[non_exhaustive]
pub struct ScanConfig { pub max_file_size_bytes: Option<u64>, pub excludes: Vec<Glob>, pub follow_symlinks: bool, }
Expand description

Configuration for a Scanner. Construct via ScanConfig::default then layer on options with the with_* / add_* builder methods, or build from struct literal during the same crate.

#[non_exhaustive] — same forward-compat reasoning as ScanEntry.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§max_file_size_bytes: Option<u64>

Skip files whose size exceeds this limit, in bytes. None means no cap (the default — a Scanner::walk call will happily yield a 50 GB file if the caller asked for it).

§excludes: Vec<Glob>
Available on crate feature walk only.

Glob patterns matched against the full path; matching files (and directories — globs match **/.git/** against e.g. /Users/me/proj/.git/HEAD and exclude the whole subtree) are silently skipped. Empty by default; build the set with ScanConfig::add_exclude.

We hold the source Globs rather than a built GlobSet because GlobSet is immutable post-build and doesn’t expose its members for round-tripping. Scanner::new builds the GlobSet once at construction time from this list.

§follow_symlinks: bool

When true, follow symlinks as if they were real files. When false (default), symlinks are skipped. Following symlinks risks both infinite loops (handled by walkdir) and crossing out of the tree the user thought they were scanning.

Implementations§

Source§

impl ScanConfig

Source

pub fn max_file_size_bytes(self, bytes: u64) -> Self

Set the per-file size cap. Files larger than bytes are silently skipped during the walk.

Toggle symlink following. Off by default.

Source

pub fn add_exclude(self, pattern: &str) -> Result<Self>

Available on crate feature walk only.

Add a glob pattern to the exclude set. Patterns are matched against the full absolute path; use ** to match any path segment.

Examples:

  • **/.git/** — exclude every .git directory
  • **/*.log — exclude every .log file
  • **/node_modules/** — exclude every node_modules tree

Returns Self so calls can chain. Returns Err when the pattern is malformed (typically a stray \ or unbalanced [...]).

Trait Implementations§

Source§

impl Clone for ScanConfig

Source§

fn clone(&self) -> ScanConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScanConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ScanConfig

Source§

fn default() -> ScanConfig

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.