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
//! `PackageSource` trait — abstract read access to a DOCX/OPC package.
use crateResult;
/// Read-only access to a DOCX package (ZIP/OPC archive).
///
/// Implemented by [`ZipPackageSource`] for file/stream-backed packages and by
/// [`InMemoryPackageSource`] for in-memory packages used in tests.
///
/// Higher-level layers depend on this trait rather than any concrete ZIP type,
/// which keeps the templating engine independent of storage format.
///
/// # Contract
///
/// - `part_names` returns only **safe** part names (no path traversal).
/// - `read_part` returns `None` for unknown parts, never an error for "not found".
/// - Part names use forward slashes as separators and do NOT start with `/`.
///
/// [`ZipPackageSource`]: crate::package::ZipPackageSource
/// [`InMemoryPackageSource`]: crate::package::InMemoryPackageSource