Struct GlobWalkerBuilder
struct GlobWalkerBuilder { ... }
An iterator for recursively yielding glob matches.
The order of elements yielded by this iterator is unspecified.
Implementations
impl GlobWalkerBuilder
fn new<P, S>(base: P, pattern: S) -> Self where P: AsRef<Path>, S: AsRef<str>Construct a new
GlobWalkerwith a glob pattern.When iterated, the
basedirectory will be recursively searched for paths matchingpattern.fn from_patterns<P, S>(base: P, patterns: &[S]) -> Self where P: AsRef<Path>, S: AsRef<str>Construct a new
GlobWalkerfrom a list of patterns.When iterated, the
basedirectory will be recursively searched for paths matchingpatterns.fn min_depth(self: Self, depth: usize) -> SelfSet the minimum depth of entries yielded by the iterator.
The smallest depth is
0and always corresponds to the path given to thenewfunction on this type. Its direct descendents have depth1, and their descendents have depth2, and so on.fn max_depth(self: Self, depth: usize) -> SelfSet the maximum depth of entries yield by the iterator.
The smallest depth is
0and always corresponds to the path given to thenewfunction on this type. Its direct descendents have depth1, and their descendents have depth2, and so on.Note that this will not simply filter the entries of the iterator, but it will actually avoid descending into directories when the depth is exceeded.
fn follow_links(self: Self, yes: bool) -> SelfFollow symbolic links. By default, this is disabled.
When
yesistrue, symbolic links are followed as if they were normal directories and files. If a symbolic link is broken or is involved in a loop, an error is yielded.When enabled, the yielded
DirEntryvalues represent the target of the link while the path corresponds to the link. See theDirEntrytype for more details.fn max_open(self: Self, n: usize) -> SelfSet the maximum number of simultaneously open file descriptors used by the iterator.
nmust be greater than or equal to1. Ifnis0, then it is set to1automatically. If this is not set, then it defaults to some reasonably low number.This setting has no impact on the results yielded by the iterator (even when
nis1). Instead, this setting represents a trade off between scarce resources (file descriptors) and memory. Namely, when the maximum number of file descriptors is reached and a new directory needs to be opened to continue iteration, then a previous directory handle is closed and has its unyielded entries stored in memory. In practice, this is a satisfying trade off because it scales with respect to the depth of your file tree. Therefore, low values (even1) are acceptable.Note that this value does not impact the number of system calls made by an exhausted iterator.
Platform behavior
On Windows, if
follow_linksis enabled, then this limit is not respected. In particular, the maximum number of file descriptors opened is proportional to the depth of the directory tree traversed.fn sort_by<F>(self: Self, cmp: F) -> Self where F: FnMut(&DirEntry, &DirEntry) -> Ordering + Send + Sync + 'staticSet a function for sorting directory entries.
If a compare function is set, the resulting iterator will return all paths in sorted order. The compare function will be called to compare entries from the same directory.
fn contents_first(self: Self, yes: bool) -> SelfYield a directory's contents before the directory itself. By default, this is disabled.
When
yesisfalse(as is the default), the directory is yielded before its contents are read. This is useful when, e.g. you want to skip processing of some directories.When
yesistrue, the iterator yields the contents of a directory before yielding the directory itself. This is useful when, e.g. you want to recursively delete a directory.fn case_insensitive(self: Self, yes: bool) -> SelfToggle whether the globs should be matched case insensitively or not.
This is disabled by default.
fn file_type(self: Self, file_type: FileType) -> SelfToggle filtering by file type.
FileTypecan be an OR of several types.Note that not all file-types can be whitelisted by this filter (e.g. char-devices, fifos, etc.)
fn build(self: Self) -> Result<GlobWalker, GlobError>Finalize and build a
GlobWalkerinstance.
impl Freeze for GlobWalkerBuilder
impl RefUnwindSafe for GlobWalkerBuilder
impl Send for GlobWalkerBuilder
impl Sync for GlobWalkerBuilder
impl Unpin for GlobWalkerBuilder
impl UnsafeUnpin for GlobWalkerBuilder
impl UnwindSafe for GlobWalkerBuilder
impl<T> Any for GlobWalkerBuilder
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for GlobWalkerBuilder
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for GlobWalkerBuilder
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for GlobWalkerBuilder
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Pointable for GlobWalkerBuilder
unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T, U> Into for GlobWalkerBuilder
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for GlobWalkerBuilder
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for GlobWalkerBuilder
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>