Debian Codegraph @

src/fs.rs

raw symbols SCIP
1 //! Filesystem utilities
2 //!
3 //! These are will be parallel if the `parallel` feature is enabled, at the expense of compiling additional dependencies
4 //! along with runtime costs for maintaining a global [`rayon`](https://docs.rs/rayon) thread pool.
5 //!
6 //! For information on how to use the [`WalkDir`] type, have a look at
7 // TODO: Move all this to `gix-fs` in a breaking change.
8
9 #[cfg(feature = "walkdir")]
10 mod sharedrust-analyzer cargo gix-features 0.48.0 fs/shared/ {
11 /// The desired level of parallelism.
12 pub enum Parallelismrust-analyzer cargo gix-features 0.48.0 fs/shared/Parallelism# {
13 /// Do not parallelize at all by making a serial traversal on the current thread.
14 Serialrust-analyzer cargo gix-features 0.48.0 fs/shared/Parallelism#Serial#,
15 /// Create a new thread pool for each traversal with up to 16 threads or the amount of logical cores of the machine.
16 ThreadPoolPerTraversalrust-analyzer cargo gix-features 0.48.0 fs/shared/Parallelism#ThreadPoolPerTraversal# {
17 /// The base name of the threads we create as part of the thread-pool.
18 thread_namerust-analyzer cargo gix-features 0.48.0 fs/shared/Parallelism#ThreadPoolPerTraversal#thread_name.: &'static str,
19 },
20 }
21 }
22
23 #[cfg(any(feature = "walkdir", feature = "fs-read-dir"))]
24 mod walkdir_precomposerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/ {
25 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#, ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#, pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#};
26
27 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
28 pub struct DirEntryrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#<T: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#> {
29 innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#inner.: T,
30 precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#precompose_unicode.: bool,
31 }
32
33 impl<T: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#> DirEntryrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#<T> {
34 /// Create a new instance.
35 pub fn newrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/impl#[`DirEntry<T>`]new().(inner: T, precompose_unicode: bool) -> Selfrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/impl#[`DirEntry<T>`] {
36 Selfrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/impl#[`DirEntry<T>`] {
37 innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#inner.,
38 precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#precompose_unicode.,
39 }
40 }
41 }
42
43 pub trait DirEntryApirust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi# {
44 fn pathrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi#path().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>;
45 fn file_namerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi#file_name().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#>;
46 fn file_typerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi#file_type().(&self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::FileTyperust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/FileType#>;
47 }
48
49 impl<T: DirEntryApirust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#> DirEntryrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#<T> {
50 /// Obtain the full path of this entry, possibly with precomposed unicode if enabled.
51 ///
52 /// Note that decomposing filesystem like those made by Apple accept both precomposed and
53 /// decomposed names, and consider them equal.
54 pub fn pathrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/impl#[`DirEntry<T>`]path().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#> {
55 let path = self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#inner..pathrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi#path().();
56 if self.precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#precompose_unicode. {
57 gix_utilsrust-analyzer cargo gix-utils 0.3.2 crate/::strrust-analyzer cargo gix-utils 0.3.2 str/::precompose_pathrust-analyzer cargo gix-utils 0.3.2 str/precompose_path().(path)
58 } else {
59 path
60 }
61 }
62
63 /// Obtain filen name of this entry, possibly with precomposed unicode if enabled.
64 pub fn file_namerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/impl#[`DirEntry<T>`]file_name().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#> {
65 let name = self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#inner..file_namerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi#file_name().();
66 if self.precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#precompose_unicode. {
67 gix_utilsrust-analyzer cargo gix-utils 0.3.2 crate/::strrust-analyzer cargo gix-utils 0.3.2 str/::precompose_os_stringrust-analyzer cargo gix-utils 0.3.2 str/precompose_os_string().(name)
68 } else {
69 name
70 }
71 }
72
73 /// Return the file type for the file that this entry points to.
74 ///
75 /// If `follow_links` was `true`, this is the file type of the item the link points to.
76 pub fn file_typerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/impl#[`DirEntry<T>`]file_type().(&self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::FileTyperust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/FileType#> {
77 self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#inner..file_typerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi#file_type().()
78 }
79 }
80
81 /// A platform over entries in a directory, which may or may not precompose unicode after retrieving
82 /// paths from the file system.
83 #[cfg(feature = "walkdir")]
84 pub struct WalkDirrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#<T> {
85 pub(craterust-analyzer cargo gix-features 0.48.0 crate/) innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#inner.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T>,
86 pub(craterust-analyzer cargo gix-features 0.48.0 crate/) precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#precompose_unicode.: bool,
87 }
88
89 #[cfg(feature = "walkdir")]
90 pub struct WalkDirIterrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDirIter#<T, I, E>
91 where
92 T: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<I, E>>,
93 I: DirEntryApirust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi#,
94 {
95 pub(craterust-analyzer cargo gix-features 0.48.0 crate/) innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDirIter#inner.: T,
96 pub(craterust-analyzer cargo gix-features 0.48.0 crate/) precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDirIter#precompose_unicode.: bool,
97 }
98
99 #[cfg(feature = "walkdir")]
100 impl<T, I, E> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for WalkDirIterrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDirIter#<T, I, E>
101 where
102 T: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<I, E>>,
103 I: DirEntryApirust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
104 {
105 type Itemrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/impl#[`WalkDirIter<T, I, E>`][Iterator]Item# = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<DirEntryrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#<I>, E>;
106
107 fn nextrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/impl#[`WalkDirIter<T, I, E>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/impl#[`WalkDirIter<T, I, E>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
108 self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDirIter#inner.
109 .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#next().()
110 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|res| res.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|entry| DirEntryrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#::newrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/impl#[`DirEntry<T>`]new().(entry, self.precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDirIter#precompose_unicode.)))
111 }
112 }
113 }
114
115 ///
116 #[cfg(feature = "fs-read-dir")]
117 pub mod read_dirrust-analyzer cargo gix-features 0.48.0 fs/read_dir/ {
118 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#, ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#, fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::FileTyperust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/FileType#, pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#};
119
120 /// A directory entry adding precompose-unicode support to [`std::fs::DirEntry`].
121 pub type DirEntryrust-analyzer cargo gix-features 0.48.0 fs/read_dir/DirEntry# = superrust-analyzer cargo gix-features 0.48.0 fs/::walkdir_precomposerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/::DirEntryrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::DirEntryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/DirEntry#>;
122
123 impl superrust-analyzer cargo gix-features 0.48.0 fs/::walkdir_precomposerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/::DirEntryApirust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi# for stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::DirEntryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/DirEntry# {
124 fn pathrust-analyzer cargo gix-features 0.48.0 fs/read_dir/impl#[`std::fs::DirEntry`][DirEntryApi]path().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#> {
125 self.pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[DirEntry]path().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
126 }
127
128 fn file_namerust-analyzer cargo gix-features 0.48.0 fs/read_dir/impl#[`std::fs::DirEntry`][DirEntryApi]file_name().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#> {
129 self.file_namerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[DirEntry]file_name().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
130 }
131
132 fn file_typerust-analyzer cargo gix-features 0.48.0 fs/read_dir/impl#[`std::fs::DirEntry`][DirEntryApi]file_type().(&self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<FileTyperust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/FileType#> {
133 self.file_typerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[DirEntry]file_type().()
134 }
135 }
136 }
137
138 ///
139 #[cfg(feature = "walkdir")]
140 pub mod walkdirrust-analyzer cargo gix-features 0.48.0 fs/walkdir/ {
141 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#, ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#, fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::FileTyperust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/FileType#, pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#};
142
143 pub use walkdirrust-analyzer cargo walkdir 2.5.0 crate/::Errorrust-analyzer cargo walkdir 2.5.0 error/Error#;
144 use walkdirrust-analyzer cargo walkdir 2.5.0 crate/::{DirEntryrust-analyzer cargo walkdir 2.5.0 dent/DirEntry# as DirEntryImplrust-analyzer cargo walkdir 2.5.0 dent/DirEntry#, WalkDirrust-analyzer cargo walkdir 2.5.0 WalkDir# as WalkDirImplrust-analyzer cargo walkdir 2.5.0 WalkDir#};
145
146 /// A directory entry returned by [DirEntryIter].
147 pub type DirEntryrust-analyzer cargo gix-features 0.48.0 fs/walkdir/DirEntry# = superrust-analyzer cargo gix-features 0.48.0 fs/::walkdir_precomposerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/::DirEntryrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntry#<DirEntryImplrust-analyzer cargo walkdir 2.5.0 dent/DirEntry#>;
148 /// A platform to create a [DirEntryIter] from.
149 pub type WalkDirrust-analyzer cargo gix-features 0.48.0 fs/walkdir/WalkDir# = superrust-analyzer cargo gix-features 0.48.0 fs/::walkdir_precomposerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/::WalkDirrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#<WalkDirImplrust-analyzer cargo walkdir 2.5.0 WalkDir#>;
150
151 pub use superrust-analyzer cargo gix-features 0.48.0 fs/::sharedrust-analyzer cargo gix-features 0.48.0 fs/shared/::Parallelismrust-analyzer cargo gix-features 0.48.0 fs/shared/Parallelism#;
152
153 impl superrust-analyzer cargo gix-features 0.48.0 fs/::walkdir_precomposerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/::DirEntryApirust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/DirEntryApi# for DirEntryImplrust-analyzer cargo walkdir 2.5.0 dent/DirEntry# {
154 fn pathrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[DirEntryImpl][DirEntryApi]path().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#> {
155 self.pathrust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]path().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
156 }
157
158 fn file_namerust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[DirEntryImpl][DirEntryApi]file_name().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, OsStrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsStr#> {
159 self.file_namerust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]file_name().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
160 }
161
162 fn file_typerust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[DirEntryImpl][DirEntryApi]file_type().(&self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<FileTyperust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/FileType#> {
163 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.file_typerust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]file_type().())
164 }
165 }
166
167 impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for WalkDirrust-analyzer cargo gix-features 0.48.0 fs/walkdir/WalkDir# {
168 type Itemrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[`super::walkdir_precompose::WalkDir<WalkDirImpl>`][IntoIterator]Item# = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<DirEntryrust-analyzer cargo gix-features 0.48.0 fs/walkdir/DirEntry#, walkdirrust-analyzer cargo walkdir 2.5.0 crate/::Errorrust-analyzer cargo walkdir 2.5.0 error/Error#>;
169 type IntoIterrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[`super::walkdir_precompose::WalkDir<WalkDirImpl>`][IntoIterator]IntoIter# = DirEntryIterrust-analyzer cargo gix-features 0.48.0 fs/walkdir/DirEntryIter#;
170
171 fn into_iterrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[`super::walkdir_precompose::WalkDir<WalkDirImpl>`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[`super::walkdir_precompose::WalkDir<WalkDirImpl>`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# {
172 DirEntryIterrust-analyzer cargo gix-features 0.48.0 fs/walkdir/DirEntryIter# {
173 innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDirIter#inner.: self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#inner..expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("always set (builder fix)").into_iterrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir][IntoIterator]into_iter().(),
174 precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDirIter#precompose_unicode.: self.precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#precompose_unicode.,
175 }
176 }
177 }
178
179 impl WalkDirrust-analyzer cargo gix-features 0.48.0 fs/walkdir/WalkDir# {
180 /// Set the minimum component depth of paths of entries.
181 pub fn min_depthrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[`super::walkdir_precompose::WalkDir<WalkDirImpl>`]min_depth().(mut self, min: usize) -> Selfrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[`super::walkdir_precompose::WalkDir<WalkDirImpl>`] {
182 self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#inner. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#inner..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("always set").min_depthrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]min_depth().(min));
183 self
184 }
185 /// Set the maximum component depth of paths of entries.
186 pub fn max_depthrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[`super::walkdir_precompose::WalkDir<WalkDirImpl>`]max_depth().(mut self, max: usize) -> Selfrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[`super::walkdir_precompose::WalkDir<WalkDirImpl>`] {
187 self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#inner. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#inner..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("always set").max_depthrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]max_depth().(max));
188 self
189 }
190 /// Follow symbolic links.
191 pub fn follow_linksrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[`super::walkdir_precompose::WalkDir<WalkDirImpl>`]follow_links().(mut self, toggle: bool) -> Selfrust-analyzer cargo gix-features 0.48.0 fs/walkdir/impl#[`super::walkdir_precompose::WalkDir<WalkDirImpl>`] {
192 self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#inner. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#inner..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("always set").follow_linksrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]follow_links().(toggle));
193 self
194 }
195 }
196
197 /// Instantiate a new directory iterator which will not skip hidden files, with the given level of `parallelism`.
198 ///
199 /// Use `precompose_unicode` to represent the `core.precomposeUnicode` configuration option.
200 pub fn walkdir_newrust-analyzer cargo gix-features 0.48.0 fs/walkdir/walkdir_new().(root: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, _: Parallelismrust-analyzer cargo gix-features 0.48.0 fs/shared/Parallelism#, precompose_unicode: bool) -> WalkDirrust-analyzer cargo gix-features 0.48.0 fs/walkdir/WalkDir# {
201 WalkDirrust-analyzer cargo gix-features 0.48.0 fs/walkdir/WalkDir# {
202 innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#inner.: WalkDirImplrust-analyzer cargo walkdir 2.5.0 WalkDir#::newrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]new().(root).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
203 precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#precompose_unicode.,
204 }
205 }
206
207 /// Instantiate a new directory iterator which will not skip hidden files and is sorted, with the given level of `parallelism`.
208 ///
209 /// Use `precompose_unicode` to represent the `core.precomposeUnicode` configuration option.
210 /// Use `max_depth` to limit the depth of the recursive walk.
211 /// * `0`
212 /// - Returns only the root path with no children
213 /// * `1`
214 /// - Root directory and children.
215 /// * `1..n`
216 /// - Root directory, children and {n}-grandchildren
217 pub fn walkdir_sorted_newrust-analyzer cargo gix-features 0.48.0 fs/walkdir/walkdir_sorted_new().(root: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, _: Parallelismrust-analyzer cargo gix-features 0.48.0 fs/shared/Parallelism#, max_depth: usize, precompose_unicode: bool) -> WalkDirrust-analyzer cargo gix-features 0.48.0 fs/walkdir/WalkDir# {
218 WalkDirrust-analyzer cargo gix-features 0.48.0 fs/walkdir/WalkDir# {
219 innerrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#inner.: WalkDirImplrust-analyzer cargo walkdir 2.5.0 WalkDir#::newrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]new().(root)
220 .max_depthrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]max_depth().(max_depth)
221 .sort_byrust-analyzer cargo walkdir 2.5.0 impl#[WalkDir]sort_by().(|a, b| {
222 let storage_a;
223 let storage_b;
224 let a_name = match gix_pathrust-analyzer cargo gix-path 0.12.0 crate/::os_str_into_bstrrust-analyzer cargo gix-path 0.12.0 convert/os_str_into_bstr().(a.file_namerust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]file_name().()) {
225 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(f) => f,
226 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => {
227 storage_a = a.file_namerust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]file_name().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().();
228 storage_a.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
229 }
230 };
231 let b_name = match gix_pathrust-analyzer cargo gix-path 0.12.0 crate/::os_str_into_bstrrust-analyzer cargo gix-path 0.12.0 convert/os_str_into_bstr().(b.file_namerust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]file_name().()) {
232 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(f) => f,
233 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => {
234 storage_b = b.file_namerust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]file_name().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().();
235 storage_b.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
236 }
237 };
238 // "common." < "common/" < "common0"
239 let common = a_name.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(b_name.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
240 a_name[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#common]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..cmprust-analyzer cargo bstr 1.12.1 impls/bstr/impl#[BStr][Ord]cmp().(&b_name[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#common]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().).then_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impl#[Ordering]then_with().(|| {
241 let a = a_name.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(common).or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]or_else().(|| a.file_typerust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]file_type().().is_dirrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[FileType]is_dir().().then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(&b'/'));
242 let b = b_name.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(common).or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]or_else().(|| b.file_typerust-analyzer cargo walkdir 2.5.0 dent/impl#[DirEntry]file_type().().is_dirrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[FileType]is_dir().().then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(&b'/'));
243 a.cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Ord]cmp().(&b)
244 })
245 })
246 .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
247 precompose_unicoderust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDir#precompose_unicode.,
248 }
249 }
250
251 /// The Iterator yielding directory items
252 pub type DirEntryIterrust-analyzer cargo gix-features 0.48.0 fs/walkdir/DirEntryIter# = superrust-analyzer cargo gix-features 0.48.0 fs/::walkdir_precomposerust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/::WalkDirIterrust-analyzer cargo gix-features 0.48.0 fs/walkdir_precompose/WalkDirIter#<walkdirrust-analyzer cargo walkdir 2.5.0 crate/::IntoIterrust-analyzer cargo walkdir 2.5.0 IntoIter#, DirEntryImplrust-analyzer cargo walkdir 2.5.0 dent/DirEntry#, walkdirrust-analyzer cargo walkdir 2.5.0 crate/::Errorrust-analyzer cargo walkdir 2.5.0 error/Error#>;
253 }
254
255 #[cfg(feature = "walkdir")]
256 pub use selfrust-analyzer cargo gix-features 0.48.0 fs/::walkdirrust-analyzer cargo gix-features 0.48.0 fs/walkdir/::{walkdir_newrust-analyzer cargo gix-features 0.48.0 fs/walkdir/walkdir_new()., walkdir_sorted_newrust-analyzer cargo gix-features 0.48.0 fs/walkdir/walkdir_sorted_new()., WalkDirrust-analyzer cargo gix-features 0.48.0 fs/walkdir/WalkDir#};
257
258 /// Prepare open options which won't follow symlinks when the file is opened.
259 ///
260 /// Note: only effective on unix currently.
261 pub fn open_options_no_followrust-analyzer cargo gix-features 0.48.0 fs/open_options_no_follow().() -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::OpenOptionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/OpenOptions# {
262 #[cfg_attr(not(unix), allow(unused_mut))]
263 let mut options = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::OpenOptionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/OpenOptions#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[OpenOptions]new().();
264 #[cfg(unix)]
265 {
266 /// Make sure that it's impossible to follow through to the target of symlinks.
267 /// Note that this will still follow symlinks in the path, which is what we assume
268 /// has been checked separately.
269 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/::OpenOptionsExtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/OpenOptionsExt#;
270 options.custom_flagsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/impl#[OpenOptions][OpenOptionsExt]custom_flags().(libcrust-analyzer cargo libc 0.2.185 crate/::O_NOFOLLOWrust-analyzer cargo libc 0.2.185 unix/linux_like/linux/gnu/b64/x86_64/O_NOFOLLOW.);
271 }
272 options
273 }