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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
//! Core traits for the version control handler.
//!
//! Each submodule defines a single trait, keeping concerns separated.
//! All traits are re-exported at the crate root for convenience.
//!
//! # Purpose
//!
//! This module is the internal home for all behavior contracts in the crate.
//! Each trait is placed in its own submodule to maintain a clean separation
//! of concerns and to keep individual files focused. The traits defined here
//! are re-exported at `libvctrl_handler` (crate root) so that downstream
//! code can import them without delving into the module hierarchy.
//!
//! # Trait Overview
//!
//! The following traits are defined in this module:
//!
//! - [`Decoder`](crate::Decoder) – deserializes version control objects from
//! byte slices.
//! - [`Encoder`](crate::Encoder) – serializes version control objects into
//! byte vectors.
//! - [`Hasher`](crate::Hasher) – computes cryptographic hashes for content
//! addressing.
//! - [`ObjectStore`](crate::ObjectStore) – manages content-addressable
//! storage of raw objects.
//! - [`RefStore`](crate::RefStore) – stores and retrieves named references
//! such as branches and tags.
//! - [`Signer`](crate::Signer) – produces cryptographic signatures over data.
//! - [`Transport`](crate::Transport) – abstracts remote object synchronization.
//! - [`Verifier`](crate::Verifier) – verifies cryptographic signatures.
//!
//! # Design Rationale
//!
//! The decision to place each trait in its own file under `core` provides
//! several benefits:
//!
//! - **Maintainability**: Each file contains only one trait and its
//! associated documentation, making it easier to navigate and update.
//! - **Reduced merge conflicts**: In a collaborative project, developers
//! working on different traits are less likely to modify the same file.
//! - **Clear responsibility boundaries**: The module structure mirrors the
//! separation of concerns in the design.
//! - **Stable public API**: The crate root re-exports keep the public surface
//! unchanged even if internal module paths evolve.
//!
//! # How to Use
//!
//! You can import individual traits directly from the crate root:
//!
//! ```
//! use libvctrl_handler::{Hasher, ObjectStore, Encoder};
//! ```
//!
//! Or, if you prefer the full path:
//!
//! ```
//! use libvctrl_handler::traits::core::hasher::Hasher;
//! ```
//!
//! Both styles refer to the same trait. The crate root re-export is the
//! recommended approach for ergonomic code.
//!
//! # Example: Checking Trait Existence
//!
//! The following example demonstrates that the traits are publicly accessible
//! and can be used as bounds:
//!
//! ```
//! use libvctrl_handler::traits::core::hasher::Hasher;
//!
//! fn assert_hasher<T: Hasher>() {}
//! ```
//!
//! # Internal Note
//!
//! The `core` module itself is not intended for direct external use beyond
//! advanced scenarios; the crate root re-exports provide the primary API.
/// Defines the `Decoder` trait for deserializing objects.
///
/// # Purpose
///
/// The [`Decoder`](crate::Decoder) trait provides the contract for converting
/// byte slices back into in-memory version control objects like
/// [`Blob`](crate::Blob), [`Tree`](crate::Tree), [`Commit`](crate::Commit),
/// and [`Tag`](crate::Tag).
///
/// # Why a separate module
///
/// Keeping the trait in its own file isolates serialization-related concerns
/// and makes the trait easy to locate. It also allows future extensions to
/// the decoding interface without affecting other modules.
///
/// # Examples
///
/// Importing the trait from this module:
///
/// ```
/// use libvctrl_handler::traits::core::decoder::Decoder;
///
/// fn assert_decoder<T: Decoder>() {}
/// ```
///
/// The same trait is available at the crate root:
///
/// ```
/// use libvctrl_handler::Decoder;
/// ```
/// Defines the `Encoder` trait for serializing objects.
///
/// # Purpose
///
/// The [`Encoder`](crate::Encoder) trait defines how version control objects
/// are transformed into byte vectors suitable for storage or transport.
///
/// # Why a separate module
///
/// Serialization logic is kept distinct from deserialization and other
/// concerns, promoting a clean separation of responsibilities. This also
/// allows encoder implementations to be swapped independently.
///
/// # Examples
///
/// Importing the trait from this module:
///
/// ```
/// use libvctrl_handler::traits::core::encoder::Encoder;
///
/// fn assert_encoder<T: Encoder>() {}
/// ```
///
/// The crate root also re-exports it:
///
/// ```
/// use libvctrl_handler::Encoder;
/// ```
/// Defines the `Hasher` trait for content addressing.
///
/// # Purpose
///
/// The [`Hasher`](crate::Hasher) trait provides the contract for computing
/// cryptographic hashes from raw data, which is fundamental to
/// content-addressable storage.
///
/// # Why a separate module
///
/// Hashing algorithms can vary (SHA-512, BLAKE3, etc.). Keeping the trait
/// isolated allows the rest of the system to remain agnostic to the specific
/// hash function used.
///
/// # Examples
///
/// Importing the trait from this module:
///
/// ```
/// use libvctrl_handler::traits::core::hasher::Hasher;
///
/// fn assert_hasher<T: Hasher>() {}
/// ```
///
/// The crate root provides the same trait:
///
/// ```
/// use libvctrl_handler::Hasher;
/// ```
/// Defines the `ObjectStore` trait for content-addressable storage.
///
/// # Purpose
///
/// The [`ObjectStore`](crate::ObjectStore) trait defines how raw objects are
/// stored and retrieved using their [`Hash`](crate::Hash) as the key. It
/// supports streaming reads to avoid large allocations.
///
/// # Why a separate module
///
/// Storage backends can be in-memory, on-disk, or remote. Isolating the trait
/// keeps the storage abstraction clean and testable.
///
/// # Examples
///
/// Importing the trait from this module:
///
/// ```
/// use libvctrl_handler::traits::core::object_store::ObjectStore;
///
/// fn assert_object_store<T: ObjectStore>() {}
/// ```
///
/// The crate root re-exports it:
///
/// ```
/// use libvctrl_handler::ObjectStore;
/// ```
/// Defines the `RefStore` trait for named references.
///
/// # Purpose
///
/// The [`RefStore`](crate::RefStore) trait manages human-readable names
/// (like branch and tag names) that point to specific object hashes.
///
/// # Why a separate module
///
/// Reference storage is conceptually distinct from object storage, even
/// though both are persistence concerns. Keeping the trait separate allows
/// independent evolution.
///
/// # Examples
///
/// Importing the trait from this module:
///
/// ```
/// use libvctrl_handler::traits::core::ref_store::RefStore;
///
/// fn assert_ref_store<T: RefStore>() {}
/// ```
///
/// The crate root also re-exports it:
///
/// ```
/// use libvctrl_handler::RefStore;
/// ```
/// Defines the `Signer` trait for cryptographic signatures.
///
/// # Purpose
///
/// The [`Signer`](crate::Signer) trait provides the ability to produce
/// cryptographic signatures over arbitrary data, typically used for commit
/// or tag signing.
///
/// # Why a separate module
///
/// Signature algorithms (Ed25519, RSA, etc.) vary by backend. Keeping the
/// signing contract isolated allows the core system to remain agnostic to
/// the specific cryptographic primitives.
///
/// # Examples
///
/// Importing the trait from this module:
///
/// ```
/// use libvctrl_handler::traits::core::signer::Signer;
///
/// fn assert_signer<T: Signer>() {}
/// ```
///
/// The crate root re-exports it:
///
/// ```
/// use libvctrl_handler::Signer;
/// ```
/// Defines the `Transport` trait for remote synchronization.
///
/// # Purpose
///
/// The [`Transport`](crate::Transport) trait abstracts the network layer used
/// to fetch and push objects between repositories.
///
/// # Why a separate module
///
/// Transport mechanisms (HTTP, SSH, custom protocols) are independent of
/// storage and serialization. Isolating the trait allows flexible
/// implementations.
///
/// # Examples
///
/// Importing the trait from this module:
///
/// ```
/// use libvctrl_handler::traits::core::transport::Transport;
///
/// fn assert_transport<T: Transport>() {}
/// ```
///
/// The crate root provides the same trait:
///
/// ```
/// use libvctrl_handler::Transport;
/// ```
/// Defines the `Verifier` trait for signature verification.
///
/// # Purpose
///
/// The [`Verifier`](crate::Verifier) trait provides the capability to verify
/// cryptographic signatures against data, ensuring authenticity and
/// integrity.
///
/// # Why a separate module
///
/// Verification is often paired with signing but can be implemented
/// separately. Keeping it in its own module allows independent testing and
/// alternative verification algorithms.
///
/// # Examples
///
/// Importing the trait from this module:
///
/// ```
/// use libvctrl_handler::traits::core::verifier::Verifier;
///
/// fn assert_verifier<T: Verifier>() {}
/// ```
///
/// The crate root re-exports it:
///
/// ```
/// use libvctrl_handler::Verifier;
/// ```