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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
use crateExtractionHandle;
use ;
use VarMap;
/// Return value used by analyzers and extractors to steer the scan.
///
/// Every analyzer and extractor invocation returns a `NextAction` that
/// tells the scanner what to do next. This lets a single plugin either
/// short-circuit the current object or abort the entire scan.
/// Metadata for a single entry produced by a [`ContentExtractor`].
///
/// An extractor advertises the next item it is about to extract via
/// this struct. The scanner uses it to apply
/// [`Filter`](crate::Filter) rules cheaply (path + size) before asking
/// the extractor to materialize the actual [`Content`].
/// A plugin that inspects a piece of content and records information.
///
/// Analyzers are the "read-only" half of the framework: they observe
/// content and write findings into the [`Context`] (global, per-scan,
/// or per-object [`VarMap`]s). They do not produce new content — for
/// that, use a [`ContentExtractor`].
///
/// Analyzers can be registered per [`ContentType`] via
/// [`ScannerBuilder::add_analyzer`](crate::ScannerBuilder::add_analyzer)
/// or as generic (all types) plugins via
/// [`ScannerBuilder::add_generic_analyzer`](crate::ScannerBuilder::add_generic_analyzer).
/// A plugin that produces child content items from a parent.
///
/// Extractors are the "recursion" half of the framework. Typical
/// examples: an archive extractor emitting each stored file, an
/// executable extractor emitting resource sections, a text extractor
/// emitting embedded numeric tokens, and so on.
///
/// The scanner drives an extractor as a short session keyed by an
/// opaque [`ExtractionHandle`]:
///
/// 1. [`acquire`](Self::acquire) is called once per parent content. If
/// it returns `None`, this extractor is skipped for the parent.
/// Otherwise the returned handle identifies the session and is
/// passed to every subsequent call.
/// 2. [`advance`](Self::advance) is called repeatedly with that
/// handle. Each call returns metadata for the next available
/// entry, or `None` when the extractor is exhausted.
/// 3. For each accepted entry, [`extract`](Self::extract) is called
/// (with the same handle) to materialize a [`Content`] object which
/// is then scanned recursively (subject to the configured max
/// depth).
/// 4. [`release`](Self::release) is always called exactly once for a
/// successfully acquired handle, whether the stream ended
/// normally, a filter skipped every entry, or the scan aborted
/// early with [`NextAction::Skip`] / [`NextAction::Exit`].
///
/// The handle lets a single extractor instance keep per-session state
/// (cursor, buffers, open archive handles, …) even when extractions
/// nest or interleave. Handles are minted by an
/// [`ExtractionPool`](crate::ExtractionPool), which owns the state
/// behind them: call
/// [`acquire_slot`](crate::ExtractionPool::acquire_slot) in `acquire`,
/// [`get`](crate::ExtractionPool::get) /
/// [`get_mut`](crate::ExtractionPool::get_mut) in `advance` and
/// `extract`, and
/// [`release_slot`](crate::ExtractionPool::release_slot) in `release`.
///
/// Extractors can be registered per [`ContentType`] via
/// [`ScannerBuilder::add_extractor`](crate::ScannerBuilder::add_extractor)
/// or as generic (all types) plugins via
/// [`ScannerBuilder::add_generic_extractor`](crate::ScannerBuilder::add_generic_extractor).
/// Fast, declarative way to identify a content type without running
/// custom code.
///
/// A [`ContentIdentifier`] can return one of these variants from
/// [`identify_method`](ContentIdentifier::identify_method) so the
/// scanner can build efficient matchers (tries, magic tables, etc.)
/// once and reuse them for every scanned object.
///
/// If none of the variants fit your identifier, return `None` from
/// `identify_method` and perform your own check inside
/// [`validate`](ContentIdentifier::validate).
/// A plugin that classifies content into a [`ContentType`].
///
/// Identifiers pair a fast pre-filter ([`IdentifyMethod`]) with an
/// optional custom [`validate`](Self::validate) step. The scanner
/// first uses the pre-filter to narrow down candidate types and then
/// calls `validate` to accept or reject each candidate.
///
/// Register identifiers via
/// [`ScannerBuilder::add_identifier`](crate::ScannerBuilder::add_identifier).
/// Only one identifier is allowed per [`ContentType`].