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
//! # `libvctrl_handler`
//!
//! A robust, pure-Rust implementation of Git internals, designed for
//! high-performance and enterprise-grade reliability.
//!
//! ## Architecture
//!
//! The crate is strictly separated into distinct domains of responsibility:
//!
//! - **[`constants`]**: Defines hard limits and magic numbers used across the crate to prevent
//! unbounded memory allocation and ensure protocol compliance.
//! - **[`enums`]**: Provides exhaustive enumerations for Git-specific types, such as tree entry kinds.
//! - **[`errors`]**: Centralizes all error handling via the [`VctrlError`] enum, ensuring consistent
//! error propagation and diagnostics.
//! - **[`macros`]**: Exposes declarative macros to reduce boilerplate for error construction.
//! - **[`traits`]**: Defines the core abstract behaviors (e.g., [`Encoder`], [`Decoder`], [`ObjectStore`]).
//! This allows consumers to plug in their own backends (in-memory, filesystem, network).
//! - **[`types`]**: Contains strongly-typed representations of Git objects (e.g., [`Blob`], [`Tree`], [`Commit`]).
//! - **[`validation`]**: Provides pure functions to validate inputs like names, hashes, and references
//! before they enter the system state.
//!
//! ## Safety and Idioms
//!
//! This crate enforces `#![forbid(unsafe_code)]` to guarantee memory safety without compromise.
//! It also aggressively denies clippy lints (all, pedantic, nursery) and enforces
//! `missing_docs` to ensure the public API is fully documented. The design relies on
//! Rust's zero-cost abstractions, utilizing `const fn` where possible to shift computations
//! to compile time.
//!
//! ## Examples
//!
//! *Note: The following examples assume this crate is named `libvctrl_handler`.*
//!
//! Creating a valid [`Hash`] and inspecting an [`EntryKind`]:
//!
//! ```
//! # use libvctrl_handler::{EntryKind, Hash};
//! // Hash requires exactly 64 bytes (SHA-512).
//! let raw_bytes = [0_u8; 64];
//! let hash = Hash::from_bytes(&raw_bytes);
//! assert!(hash.is_ok());
//!
//! // Git object modes can be inspected via the EntryKind enum.
//! let blob_mode = EntryKind::Blob.mode();
//! assert_eq!(blob_mode, 0o100_644);
//! ```
/// Constants related to Git object formats and operational limits.
///
/// # Why this exists
/// Git has implicit and explicit limits (like maximum blob size or tree entries).
/// Centralizing these constants prevents magic numbers across the codebase and
/// ensures that limits are uniformly enforced at the type construction level.
/// Enums for Git object types.
///
/// # Why this exists
/// Using strongly-typed enums instead of raw integers (like `u32` mode bits)
/// allows the compiler to exhaustively match object kinds, preventing invalid states
/// and making the API self-documenting.
/// Error types used throughout the crate.
///
/// # Why this exists
/// Centralizes all error variants into a single [`VctrlError`] enum. This allows
/// consumers to handle errors uniformly using the `?` operator across different subsystems
/// without needing to box or wrap disparate error types manually.
/// Helper macros for the crate.
///
/// # Why this exists
/// Provides syntactic sugar for error creation, reducing boilerplate when wrapping
/// strings into [`VctrlError::Other`] and ensuring consistent error formatting.
/// Traits defining repository operations.
///
/// # Why this exists
/// By defining traits like [`ObjectStore`] or [`Encoder`], the crate decouples
/// the business logic from the underlying I/O backend. This enables mocking
/// for tests and allows for custom storage implementations (e.g., in-memory vs. disk).
/// Core data types for Git objects.
///
/// # Why this exists
/// Provides immutable, validated structures like [`Commit`] and [`Tree`].
/// Construction is fallible, ensuring that invalid objects cannot exist at runtime.
/// Pure validation functions for Git inputs.
///
/// # Why this exists
/// Separating validation from data structures allows the same logic to be
/// applied to raw inputs before attempting object construction, failing fast
/// on malformed data and preventing invalid states from ever being created.
/// Re-exports of fundamental constants for easy access.
///
/// These limits are enforced during object construction to prevent memory exhaustion
/// and maintain Git protocol compliance.
pub use ;
/// Re-export of the [`EntryKind`] enum for classifying tree entries.
pub use EntryKind;
/// Re-export of the primary error type [`VctrlError`].
pub use VctrlError;
/// Re-exports of core operational traits for backend implementation.
///
/// Implement these traits to create a custom Git backend or to interact with
/// repository data generically.
pub use ;
/// Re-exports of strongly-typed Git object representations.
///
/// These types are the primary data carriers used in encoding, decoding, and manipulation.
pub use ;
/// Re-exports of validation utilities.
///
/// Use these functions to sanitize or verify inputs before passing them to constructors.
pub use ;