Skip to main content

Module constants

Module constants 

Source
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_SIZE and MAX_TREE_ENTRIES exist 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_LENGTH is 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-level EntryKind enum.

Modules§

entry_mode
Standard Unix filesystem mode bits used in the serialized tree format.

Constants§

HASH_LENGTH
The expected length of a Hash in 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.