Expand description
System-wide constants and structural limits.
§Purpose
Centralizes all magic numbers and structural limits used across the version control system.
§Design Rationale
Defining them in a single module ensures that validation logic in type constructors, encoders, and storage backends remains consistent and easily tunable.
§Examples
use libvctrl::constants::HASH_LENGTH;
assert_eq!(HASH_LENGTH, 64);System-wide constants and structural limits used across the version control system.
§Purpose
This module centralises all numeric constants (e.g., HASH_LENGTH,
MAX_NAME_LENGTH) so that they can be used consistently by every other
module and by downstream crates. Changing a constant here automatically
propagates to all dependent code.
§Why a separate module
Grouping constants in one module avoids circular dependencies and keeps the root namespace clean. It also makes it easy to document each constant with its own doc comment and doctest.
§Examples
use libvctrl_handler::constants::HASH_LENGTH;
assert_eq!(HASH_LENGTH, 64);System-wide constants and limits for libvctrl_handler.
§Purpose
This module centralizes all magic numbers and structural limits used across the version control system. Defining them here ensures that validation logic in type constructors, encoders, and storage backends remains consistent and easily tunable.
§Design rationale
- Resource Exhaustion Prevention: Limits like
MAX_BLOB_SIZEandMAX_TREE_ENTRIESexist to prevent malicious or accidental resource exhaustion (e.g., a 100GB blob crashing the indexer). They define safe upper bounds for memory and disk usage. - Compatibility:
HASH_LENGTHis fixed to 64 bytes (512 bits), aligning with SHA-512 or BLAKE3 (extended) outputs. - Wire Format Separation: The [
entry_mode] submodule isolates raw Unix-style mode bits used in the serialized tree format from the high-levelEntryKindenum.
Modules§
- entry_
mode - Standard Unix filesystem mode bits used in the serialized tree format.
Constants§
- HASH_
LENGTH - The expected length of a
Hashin bytes (64 bytes = 512 bits). - MAX_
BLOB_ SIZE - The maximum allowed size in bytes for a single
Blob. - MAX_
MESSAGE_ LENGTH - The maximum allowed byte length for commit or tag messages.
- MAX_
NAME_ LENGTH - The maximum allowed byte length for names (e.g., branches, tags, file entries).
- MAX_
TREE_ ENTRIES - The maximum number of entries allowed in a single
Tree.