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
//! # content_scan
//!
//! A pluggable, hierarchical content-scanning framework.
//!
//! `content_scan` provides the building blocks for walking arbitrary
//! content (files, buffers, nested archives, embedded resources, etc.),
//! identifying its type, analyzing it, and recursively extracting inner
//! content. It is intentionally transport-agnostic: the caller supplies
//! anything that implements [`Content`] and the [`Scanner`] takes care of
//! dispatch, recursion, filtering, and result aggregation.
//!
//! ## Concepts
//!
//! - **[`ContentType`]** – a user-defined enum (typically derived with
//! `#[derive(ContentType)]`) that enumerates the content kinds your
//! application understands.
//! - **[`Content`]** – a trait describing a byte-addressable piece of
//! content with a path and a size. Use [`BufferContent`] for in-memory
//! data or implement it for your own sources.
//! - **[`ContentIdentifier`]** – classifies a piece of content into a
//! `ContentType` (via magic bytes, file name, or extension) and
//! validates the guess.
//! - **[`ContentAnalyzer`]** – inspects content and records information
//! into the [`Context`] (global, per-extraction, or per-object
//! variable maps).
//! - **[`ContentExtractor`]** – produces child [`Content`] items from a
//! parent (e.g. entries of an archive). Extracted children are scanned
//! recursively up to a configurable depth.
//! - **[`Filter`]** – optional inclusion/exclusion rules applied before
//! any plugin runs on a piece of content.
//! - **[`Scanner`] / [`ScannerBuilder`]** – wires all plugins together
//! and drives a scan. The scan produces a [`ScanResult`] that can be
//! navigated as a tree of [`ScanContentHandle`]s.
//!
//! ## Example
//!
//! ```ignore
//! use content_scan::*;
//!
//! #[derive(Debug, Copy, Clone, Eq, PartialEq, ContentType)]
//! #[repr(u16)]
//! enum MyTypes { Text }
//!
//! struct TextId;
//! impl ContentIdentifier<MyTypes> for TextId {
//! fn identify_method(&self) -> Option<IdentifyMethod> {
//! Some(IdentifyMethod::Extension("txt"))
//! }
//! fn validate(&self, _: &dyn Content<MyTypes>) -> bool { true }
//! }
//!
//! let mut scanner = ScannerBuilder::<MyTypes>::new()
//! .add_identifier(MyTypes::Text, TextId)
//! .build();
//!
//! let mut content = BufferContent::<MyTypes>::new(b"hello", "hello.txt");
//! let result = scanner.scan(&mut content);
//! assert_eq!(result.objects_scanned(), 1);
//! ```
pub use *;
pub use *;
pub use *;
use *;
use *;
use Object;
use BufferArena;
pub use Scanner;
pub use ScannerBuilder;
pub use ContentType;
pub use Context;
pub use ScanResult;
pub use ScanContentHandle;
pub use *;