1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//! Configuration types: [`DirectoryFilter`] and [`TreeConfig`].
use PathBuf;
/// The default set of basenames that [`DirectoryTree`]'s v0.5 prefetch
/// machinery skips, populated into [`TreeConfig::prefetch_skip`] by
/// default.
///
/// These are directories that are commonly present, commonly *enormous*,
/// and commonly *not* what a user browses for in a tree widget:
///
/// * **Version control metadata** — `.git`, `.hg`, `.svn`. A `.git/`
/// directory alone can contain tens of thousands of tiny files
/// under `objects/`; speculatively scanning it on every repo-root
/// expansion is wasteful even on fast SSDs.
/// * **JavaScript dependencies** — `node_modules`. Frequently the
/// single largest directory in a project by both file count and
/// bytes.
/// * **Python caches and virtual environments** — `__pycache__`,
/// `.venv`, `venv`.
/// * **Build artifacts** — `target` (Rust, Java), `build`, `dist`.
///
/// The match is **exact-basename, ASCII case-insensitive**. Substring
/// matches are *not* performed — a folder named `my-target-files/`
/// is *not* skipped by the entry `"target"`.
///
/// # Overriding the default
///
/// This list is a starting point, not a contract. Apps that want to
/// skip additional directories should merge with the default:
///
/// ```ignore
/// use iced_swdir_tree::{DirectoryTree, DEFAULT_PREFETCH_SKIP};
///
/// let mut skip: Vec<String> = DEFAULT_PREFETCH_SKIP
/// .iter()
/// .map(|&s| s.to_string())
/// .collect();
/// skip.push("huge_media_library".into());
///
/// let tree = DirectoryTree::new(root)
/// .with_prefetch_limit(10)
/// .with_prefetch_skip(skip);
/// ```
///
/// Apps that want to disable skipping entirely — for example a
/// dedicated `.git/` viewer — can pass an empty list:
///
/// ```ignore
/// let tree = DirectoryTree::new(root).with_prefetch_skip(Vec::<String>::new());
/// ```
///
/// # User clicks are never skipped
///
/// This list applies *only* to automatic prefetch. If the user
/// explicitly clicks to expand a skipped folder, the widget scans
/// it normally — their click is an explicit request.
///
/// [`DirectoryTree`]: crate::DirectoryTree
pub const DEFAULT_PREFETCH_SKIP: & = &;
/// Controls which entries the widget displays.
///
/// The widget *always* scans every entry of an expanded directory
/// (swdir's `scan_dir` makes no filtering decisions); the filter is
/// applied as we normalize raw entries into [`TreeNode`]s. That means
/// a filter change takes effect on the next view without needing to
/// re-scan the filesystem.
///
/// [`TreeNode`]: crate::TreeNode
/// Per-tree configuration.
///
/// Constructed internally by [`DirectoryTree::new`] and its builder
/// methods; exposed as `pub` so tests and downstream tooling can
/// introspect the configuration.
///
/// [`DirectoryTree::new`]: crate::DirectoryTree::new