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
use HashSet;
use ;
use crateOxenError;
use crateMerkleHash;
/// Wire-format selector for [`MerklePacker::pack_nodes`].
///
/// Two on-the-wire tar-gz layouts have coexisted as long as the merkle transport has
/// existed. Each call site must pick the variant that matches the peer it's writing
/// to; the trait makes no claim that a single canonical format exists.
// **No `Default` impl on purpose.** Picking a wire format is a protocol decision and
// must be made explicitly at every call site. **No `#[non_exhaustive]` on purpose.**
// Adding a future variant should be a deliberate breaking change that surfaces at
// every match arm — compile errors are the forcing function.
/// Per-call extraction policy for [`MerkleUnpacker::unpack`].
///
/// **No `Default` impl on purpose.** The choice between overwriting and skipping is
/// path-dependent and must be made explicitly at every call site.
// **No `#[non_exhaustive]` on purpose** for the same reason as [`PackOptions`].
/// Produce transport-ready bytes from some subset (or all) of the backend's Merkle tree nodes.
///
/// Writes a tar-gz wire stream directly into the caller-provided sink. No buffer is
/// materialized inside the trait, so memory use is O(compressor window). Callers can
/// plug in HTTP response bodies, pipes, files, or in-memory `Vec<u8>` sinks as the writer.
///
/// dyn-compatible: callers can store this as `Box<dyn MerklePacker + '_>` or
/// `&dyn MerklePacker`. Methods take `&mut dyn Write` instead of generic `W: Write`
/// so the trait carries no per-call type parameters.
/// Consume transport bytes and install the nodes they contain into the backend.
///
/// Reads the tar-gz wire format incrementally from `reader`. Nothing buffers the full
/// payload inside the trait. Async callers bridge a `Stream<Item = Bytes>` to a sync
/// [`Read`] via [`tokio_util::io::SyncIoBridge`] inside a [`tokio::task::spawn_blocking`].
///
/// dyn-compatible: callers can store this as `Box<dyn MerkleUnpacker + '_>` or
/// `&dyn MerkleUnpacker`. The reader is taken as `&mut dyn Read` for the same
/// reason as [`MerklePacker`]'s `&mut dyn Write` argument.
/// Marker super-trait: a type that can both pack and unpack Merkle tree nodes for transport.
/// This blanket impl makes any type that implements [`MerklePacker`] and
/// [`MerkleUnpacker`] automatically a [`MerkleTransport`]. The `?Sized` bound lets
/// the marker apply to `dyn MerkleTransport` itself, so the impl works for both
/// concrete backends and trait-object views over them.