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
//! Shared fixtures for the crate's own tests.
//!
//! Gated behind the `test-utils` feature flag. The contents of this module
//! are **not part of the stable public API** — they exist so that unit tests
//! inside this crate and integration tests in `tests/` can share the same
//! chunk-framing boilerplate without re-implementing it per file. Anything
//! exposed here can change between minor versions without notice.
//!
//! External consumers writing their own integration tests against synthetic
//! patches may opt into this module by enabling the `test-utils` feature in
//! their `Cargo.toml`, but should understand they are pinning to an internal
//! testing aid rather than a versioned public API.
/// The 12-byte `ZiPatch` file magic: `\x91ZIPATCH\r\n\x1a\n`.
///
/// Every well-formed `ZiPatch` stream begins with these exact bytes;
/// [`crate::ZiPatchReader::new`] validates them on construction.
pub const MAGIC: = ;
/// Wrap `tag` + `body` into a well-formed chunk frame.
///
/// The on-disk layout is `[body_len: u32 BE | tag: 4 | body | CRC32: u32 BE]`,
/// where the CRC32 is computed over `tag ++ body` (the leading length is *not*
/// included). This matches the wire format consumed by
/// [`crate::ZiPatchReader`].
///
/// # Panics
///
/// Panics if `body.len()` does not fit in a `u32`. The on-wire length field is
/// 32 bits and the parser already rejects oversized chunks, so this is a
/// genuine programmer error rather than a runtime concern.
/// Assemble a complete patch stream from a sequence of pre-framed chunks.
///
/// Prepends [`MAGIC`] to the concatenation of `chunks`. Callers are responsible
/// for terminating the stream with an `EOF_` chunk if [`crate::ZiPatchReader`]
/// is to see the patch as complete.