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
//! Fundamental contracts for building a version control system.
//!
//! # Purpose
//! `libvctrl_handler` provides the core, pure-data types and behavior traits
//! required to construct a version control system (VCS). It intentionally
//! contains *no implementations*—only the abstract definitions of objects
//! (blobs, trees, commits, tags) and the interfaces for storing, hashing,
//! encoding, and transporting them.
//!
//! # Design rationale
//! The crate enforces a strict separation between data and behavior:
//! - **Data** is represented by immutable structs in [`types`].
//! - **Behavior** is defined by traits in [`traits`].
//!
//! This decoupling allows downstream applications to mix and match backends
//! (e.g., an in-memory store with a binary encoder and Ed25519 signing) without
//! altering the core domain logic. The crate is built with strict Clippy lints
//! (`pedantic`, `nursery`) and forbids `unsafe` code to guarantee memory safety
//! and high code quality.
//!
//! # Internal mechanism
//! The crate exports all public types, traits, and constants at the root level
//! for convenience. Consumers can simply `use libvctrl_handler::*;` to access
//! the entire contract surface.
//!
//! # Examples
//!
//! Constructing a basic object and hash:
//!
//! ```
//! use libvctrl_handler::{Blob, Hash};
//!
//! let blob = Blob::new(b"content".to_vec());
//! let hash = Hash::from_bytes(&[0u8; 64]).unwrap();
//! assert_eq!(blob.size(), 7);
//! assert_eq!(hash.as_bytes().len(), 64);
//! ```
/// System-wide constants and structural limits used across the version control system.
///
/// # Examples
///
/// ```
/// use libvctrl_handler::constants::HASH_LENGTH;
/// assert_eq!(HASH_LENGTH, 64);
/// ```
/// Logical object type enumerations, distinguishing between files and directories.
///
/// # Examples
///
/// ```
/// use libvctrl_handler::enums::EntryKind;
/// assert_ne!(EntryKind::Blob, EntryKind::Tree);
/// ```
/// Unified error handling for all fallible operations within the crate.
///
/// # Examples
///
/// ```
/// use libvctrl_handler::errors::VctrlError;
/// let err = VctrlError::Other("fail".to_string());
/// assert_eq!(err.to_string(), "fail");
/// ```
/// Helper macros for ergonomic error construction.
///
/// # Examples
///
/// ```
/// use libvctrl_handler::VctrlError;
/// use libvctrl_handler::vctrl_error_other;
///
/// let err: VctrlError = vctrl_error_other!("code {}", 500);
/// assert_eq!(err.to_string(), "code 500");
/// ```
/// Core behavior contracts (traits) for storage, encoding, hashing, and transport.
///
/// # Examples
///
/// ```
/// use libvctrl_handler::traits::Hasher;
/// use libvctrl_handler::Hash;
///
/// struct DummyHasher;
/// impl Hasher for DummyHasher {
/// fn hash(&self, _data: &[u8]) -> Hash {
/// Hash::from_bytes(&[0u8; 64]).unwrap()
/// }
/// }
/// ```
/// Core data structures representing version control objects.
///
/// # Examples
///
/// ```
/// use libvctrl_handler::types::Blob;
/// let blob = Blob::new(vec![1, 2, 3]);
/// assert_eq!(blob.size(), 3);
/// ```
/// Re-exports of fundamental system constants like [`HASH_LENGTH`](crate::constants::HASH_LENGTH) and maximum size limits.
///
/// # Examples
///
/// ```
/// use libvctrl_handler::HASH_LENGTH;
/// assert_eq!(HASH_LENGTH, 64);
/// ```
pub use ;
/// Re-export of the [`EntryKind`](crate::enums::EntryKind) enum.
///
/// # Examples
///
/// ```
/// use libvctrl_handler::EntryKind;
/// assert_eq!(EntryKind::Blob, EntryKind::Blob);
/// ```
pub use EntryKind;
/// Re-export of the unified [`VctrlError`](crate::errors::VctrlError) type.
///
/// # Examples
///
/// ```
/// use libvctrl_handler::VctrlError;
/// let err = VctrlError::Other("test".to_string());
/// assert!(err.to_string().contains("test"));
/// ```
pub use VctrlError;
/// Re-exports of the core behavior traits (e.g., [`ObjectStore`](crate::traits::ObjectStore), [`Hasher`](crate::traits::Hasher)).
///
/// # Examples
///
/// ```
/// use libvctrl_handler::{Hasher, Hash};
///
/// struct MyHasher;
/// impl Hasher for MyHasher {
/// fn hash(&self, _data: &[u8]) -> Hash {
/// Hash::from_bytes(&[0u8; 64]).unwrap()
/// }
/// }
/// ```
pub use ;
/// Re-exports of the core data structures (e.g., [`Blob`](crate::types::Blob), [`Commit`](crate::types::Commit)).
///
/// # Examples
///
/// ```
/// use libvctrl_handler::Blob;
/// let blob = Blob::new(vec![1, 2, 3]);
/// assert_eq!(blob.size(), 3);
/// ```
pub use ;