1use super::matchers;
2use super::Matcher;
3
4#[derive(Debug, Eq, PartialEq)]
5pub enum MatcherType {
6 APP,
7 ARCHIVE,
8 AUDIO,
9 DOC,
10 FONT,
11 IMAGE,
12 VIDEO,
13 CUSTOM,
14}
15
16macro_rules! matcher_map {
17 ($(($mtype:expr, $mime:literal, $ext:literal, $matcher:expr)),*) => {
18 pub const MATCHER_MAP: &[(MatcherType, &'static str, &'static str, Matcher)] = &[
19 $(($mtype, $mime, $ext, $matcher as Matcher),)*
20 ];
21 };
22}
23
24matcher_map!(
28 (
30 MatcherType::APP,
31 "application/wasm",
32 "wasm",
33 matchers::app::is_wasm
34 ),
35 (
36 MatcherType::APP,
37 "application/x-executable",
38 "elf",
39 matchers::app::is_elf
40 ),
41 (
42 MatcherType::APP,
43 "application/vnd.microsoft.portable-executable",
44 "exe",
45 matchers::app::is_exe
46 ),
47 (
48 MatcherType::APP,
49 "application/java",
50 "class",
51 matchers::app::is_java
52 ),
53 (
54 MatcherType::APP,
55 "application/x-llvm",
56 "bc",
57 matchers::app::is_llvm
58 ),
59 (
61 MatcherType::IMAGE,
62 "image/jpeg",
63 "jpg",
64 matchers::image::is_jpeg
65 ),
66 (
67 MatcherType::IMAGE,
68 "image/jp2",
69 "jp2",
70 matchers::image::is_jpeg2000
71 ),
72 (
73 MatcherType::IMAGE,
74 "image/png",
75 "png",
76 matchers::image::is_png
77 ),
78 (
79 MatcherType::IMAGE,
80 "image/gif",
81 "gif",
82 matchers::image::is_gif
83 ),
84 (
85 MatcherType::IMAGE,
86 "image/webp",
87 "webp",
88 matchers::image::is_webp
89 ),
90 (
91 MatcherType::IMAGE,
92 "image/x-canon-cr2",
93 "cr2",
94 matchers::image::is_cr2
95 ),
96 (
97 MatcherType::IMAGE,
98 "image/tiff",
99 "tif",
100 matchers::image::is_tiff
101 ),
102 (
103 MatcherType::IMAGE,
104 "image/bmp",
105 "bmp",
106 matchers::image::is_bmp
107 ),
108 (
109 MatcherType::IMAGE,
110 "image/vnd.ms-photo",
111 "jxr",
112 matchers::image::is_jxr
113 ),
114 (
115 MatcherType::IMAGE,
116 "image/vnd.adobe.photoshop",
117 "psd",
118 matchers::image::is_psd
119 ),
120 (
121 MatcherType::IMAGE,
122 "image/vnd.microsoft.icon",
123 "ico",
124 matchers::image::is_ico
125 ),
126 (
127 MatcherType::IMAGE,
128 "image/heif",
129 "heif",
130 matchers::image::is_heif
131 ),
132 (
133 MatcherType::IMAGE,
134 "image/avif",
135 "avif",
136 matchers::image::is_avif
137 ),
138 (
140 MatcherType::VIDEO,
141 "video/mp4",
142 "mp4",
143 matchers::video::is_mp4
144 ),
145 (
146 MatcherType::VIDEO,
147 "video/x-m4v",
148 "m4v",
149 matchers::video::is_m4v
150 ),
151 (
152 MatcherType::VIDEO,
153 "video/x-matroska",
154 "mkv",
155 matchers::video::is_mkv
156 ),
157 (
158 MatcherType::VIDEO,
159 "video/webm",
160 "webm",
161 matchers::video::is_webm
162 ),
163 (
164 MatcherType::VIDEO,
165 "video/quicktime",
166 "mov",
167 matchers::video::is_mov
168 ),
169 (
170 MatcherType::VIDEO,
171 "video/x-msvideo",
172 "avi",
173 matchers::video::is_avi
174 ),
175 (
176 MatcherType::VIDEO,
177 "video/x-ms-wmv",
178 "wmv",
179 matchers::video::is_wmv
180 ),
181 (
182 MatcherType::VIDEO,
183 "video/mpeg",
184 "mpg",
185 matchers::video::is_mpeg
186 ),
187 (
188 MatcherType::VIDEO,
189 "video/x-flv",
190 "flv",
191 matchers::video::is_flv
192 ),
193 (
195 MatcherType::AUDIO,
196 "audio/midi",
197 "midi",
198 matchers::audio::is_midi
199 ),
200 (
201 MatcherType::AUDIO,
202 "audio/mpeg",
203 "mp3",
204 matchers::audio::is_mp3
205 ),
206 (
207 MatcherType::AUDIO,
208 "audio/m4a",
209 "m4a",
210 matchers::audio::is_m4a
211 ),
212 (
213 MatcherType::AUDIO,
214 "audio/ogg",
215 "ogg",
216 matchers::audio::is_ogg
217 ),
218 (
219 MatcherType::AUDIO,
220 "audio/x-flac",
221 "flac",
222 matchers::audio::is_flac
223 ),
224 (
225 MatcherType::AUDIO,
226 "audio/x-wav",
227 "wav",
228 matchers::audio::is_wav
229 ),
230 (
231 MatcherType::AUDIO,
232 "audio/amr",
233 "amr",
234 matchers::audio::is_amr
235 ),
236 (
237 MatcherType::AUDIO,
238 "audio/aac",
239 "aac",
240 matchers::audio::is_aac
241 ),
242 (
244 MatcherType::FONT,
245 "application/font-woff",
246 "woff",
247 matchers::font::is_woff
248 ),
249 (
250 MatcherType::FONT,
251 "application/font-woff",
252 "woff2",
253 matchers::font::is_woff2
254 ),
255 (
256 MatcherType::FONT,
257 "application/font-sfnt",
258 "ttf",
259 matchers::font::is_ttf
260 ),
261 (
262 MatcherType::FONT,
263 "application/font-sfnt",
264 "otf",
265 matchers::font::is_otf
266 ),
267 (
269 MatcherType::DOC,
270 "application/msword",
271 "doc",
272 matchers::doc::is_doc
273 ),
274 (
275 MatcherType::DOC,
276 "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
277 "docx",
278 matchers::doc::is_docx
279 ),
280 (
281 MatcherType::DOC,
282 "application/vnd.ms-excel",
283 "xls",
284 matchers::doc::is_xls
285 ),
286 (
287 MatcherType::DOC,
288 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
289 "xlsx",
290 matchers::doc::is_xlsx
291 ),
292 (
293 MatcherType::DOC,
294 "application/vnd.ms-powerpoint",
295 "ppt",
296 matchers::doc::is_ppt
297 ),
298 (
299 MatcherType::DOC,
300 "application/application/vnd.openxmlformats-officedocument.presentationml.presentation",
301 "pptx",
302 matchers::doc::is_pptx
303 ),
304 (
306 MatcherType::ARCHIVE,
307 "application/epub+zip",
308 "epub",
309 matchers::archive::is_epub
310 ),
311 (
312 MatcherType::ARCHIVE,
313 "application/zip",
314 "zip",
315 matchers::archive::is_zip
316 ),
317 (
318 MatcherType::ARCHIVE,
319 "application/x-tar",
320 "tar",
321 matchers::archive::is_tar
322 ),
323 (
324 MatcherType::ARCHIVE,
325 "application/vnd.rar",
326 "rar",
327 matchers::archive::is_rar
328 ),
329 (
330 MatcherType::ARCHIVE,
331 "application/gzip",
332 "gz",
333 matchers::archive::is_gz
334 ),
335 (
336 MatcherType::ARCHIVE,
337 "application/x-bzip2",
338 "bz2",
339 matchers::archive::is_bz2
340 ),
341 (
342 MatcherType::ARCHIVE,
343 "application/x-7z-compressed",
344 "7z",
345 matchers::archive::is_7z
346 ),
347 (
348 MatcherType::ARCHIVE,
349 "application/x-xz",
350 "xz",
351 matchers::archive::is_xz
352 ),
353 (
354 MatcherType::ARCHIVE,
355 "application/pdf",
356 "pdf",
357 matchers::archive::is_pdf
358 ),
359 (
360 MatcherType::ARCHIVE,
361 "application/x-shockwave-flash",
362 "swf",
363 matchers::archive::is_swf
364 ),
365 (
366 MatcherType::ARCHIVE,
367 "application/rtf",
368 "rtf",
369 matchers::archive::is_rtf
370 ),
371 (
372 MatcherType::ARCHIVE,
373 "application/octet-stream",
374 "eot",
375 matchers::archive::is_eot
376 ),
377 (
378 MatcherType::ARCHIVE,
379 "application/postscript",
380 "ps",
381 matchers::archive::is_ps
382 ),
383 (
384 MatcherType::ARCHIVE,
385 "application/vnd.sqlite3",
386 "sqlite",
387 matchers::archive::is_sqlite
388 ),
389 (
390 MatcherType::ARCHIVE,
391 "application/x-nintendo-nes-rom",
392 "nes",
393 matchers::archive::is_nes
394 ),
395 (
396 MatcherType::ARCHIVE,
397 "application/x-google-chrome-extension",
398 "crx",
399 matchers::archive::is_crx
400 ),
401 (
402 MatcherType::ARCHIVE,
403 "application/vnd.ms-cab-compressed",
404 "cab",
405 matchers::archive::is_cab
406 ),
407 (
408 MatcherType::ARCHIVE,
409 "application/vnd.debian.binary-package",
410 "deb",
411 matchers::archive::is_deb
412 ),
413 (
414 MatcherType::ARCHIVE,
415 "application/x-unix-archive",
416 "ar",
417 matchers::archive::is_ar
418 ),
419 (
420 MatcherType::ARCHIVE,
421 "application/x-compress",
422 "Z",
423 matchers::archive::is_z
424 ),
425 (
426 MatcherType::ARCHIVE,
427 "application/x-lzip",
428 "lz",
429 matchers::archive::is_lz
430 ),
431 (
432 MatcherType::ARCHIVE,
433 "application/x-rpm",
434 "rpm",
435 matchers::archive::is_rpm
436 ),
437 (
438 MatcherType::ARCHIVE,
439 "application/dicom",
440 "dcm",
441 matchers::archive::is_dcm
442 ),
443 (
444 MatcherType::ARCHIVE,
445 "application/zstd",
446 "zst",
447 matchers::archive::is_zst
448 )
449);