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
//! # Types
//!
//! Fundamental data types and name validation utilities for the version control system.
//!
//! This module houses all core types—blobs, trees, commits, tags, and hashes—in the `core`
//! submodule and re-exports them for ergonomic access. It also provides shared name validation
//! functions that enforce invariants across the system.
//!
//! ## Architecture
//!
//! - `core` module: contains the structs and enums that model the object model. These types
//! implement parsing, serialization, and domain-specific behaviours.
//! - Re-export: `pub use core::*` lifts every type to `crate::types`, so consumers can write
//! `use libvctrl_handler::types::Blob` instead of `libvctrl_handler::types::core::Blob`.
//! - Validation helpers: `validate_name` and `validate_tree_entry_name` are `pub(crate)`,
//! intentionally scoped to the crate to prevent external misuse while remaining available
//! to all internal modules.
//!
//! ## Crate name assumption
//!
//! For documentation doctests this module assumes the library crate is named `libvctrl_handler`.
//! Adjust import paths accordingly when integrating into a real project.
//!
//! # Examples
//!
//! Using a re-exported type:
//!
//! ```
//! use libvctrl_handler::types::Blob;
//! let blob = Blob::new(b"hello world".to_vec());
//! ```
/// Core object-model types.
///
/// This submodule defines the fundamental building blocks of the version control system:
/// [`Blob`], [`Tree`], [`Commit`], [`Tag`], [`Hash`], and supporting types like [`UserID`].
/// Each type is designed as a plain-old-data struct with immutable fields, mirroring the
/// content-addressable storage philosophy. They are intentionally `pub` so that external
/// consumers can construct and inspect them, while mutations remain the responsibility of
/// higher-level managers.
///
/// # How it fits
///
/// The `core` module is the source of truth. Other subsystems (`traits`, `handlers`, …)
/// depend on these types through re-exports from the parent `types` module, keeping
/// dependency graphs shallow and avoiding circular imports.
///
/// # Examples
///
/// Constructing a blob through the `core` path:
///
/// ```
/// use libvctrl_handler::types::core::Blob;
/// let blob = Blob::new(b"example data".to_vec());
/// ```
use crateMAX_NAME_LENGTH;
use crateVctrlError;
/// Re-exports all types from `core` into the `types` namespace.
///
/// Without this re-export, consumers would need to write `use libvctrl_handler::types::core::Blob`.
/// By lifting them to `types`, we present a cleaner public API while keeping the
/// implementation modular.
///
/// # Examples
///
/// ```
/// use libvctrl_handler::types::Blob;
/// let blob = Blob::new(b"lifted access".to_vec());
/// ```
pub use *;
/// Validates a general-purpose name (branch, tag, remote, etc.) against length constraints.
///
/// Names are required to be non-empty and not exceed [`MAX_NAME_LENGTH`] bytes.
/// This function is `pub(crate)` because name validation is an internal invariant;
/// external users should never be able to inject a name that bypasses these checks.
///
/// # How it works
///
/// 1. Checks emptiness → early `InvalidName` error.
/// 2. Checks length against the compile-time constant `MAX_NAME_LENGTH`.
///
/// # Errors
///
/// Returns [`VctrlError::InvalidName`] with a descriptive message when the name is empty
/// or too long.
pub
/// Validates a name intended for a tree entry (file or directory name inside a tree object).
///
/// In addition to the checks performed by [`validate_name`], this function forbids:
/// - Slash characters (`/`), which would interfere with path parsing.
/// - The reserved names `.` and `..`, which have special meanings in Unix-like systems.
///
/// # Why it exists
///
/// Tree entries must be simple, flat names without directory separators. Enforcing this
/// at the validation layer prevents entire classes of path-traversal and tree-corruption
/// bugs before they reach storage.
///
/// # How it works
///
/// 1. Calls [`validate_name`] to enforce basic constraints.
/// 2. Checks for `/`, `.`, and `..` characters.
///
/// # Errors
///
/// Returns [`VctrlError::InvalidName`] if the name is empty, too long, or contains forbidden
/// characters/names.
pub