Skip to main content

Crate libvctrl_handler

Crate libvctrl_handler 

Source
Expand description

§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:

// 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);

Re-exports§

pub use constants::HASH_LENGTH;
pub use constants::MAX_BLOB_SIZE;
pub use constants::MAX_MESSAGE_LENGTH;
pub use constants::MAX_NAME_LENGTH;
pub use constants::MAX_PARENT_COUNT;
pub use constants::MAX_TREE_ENTRIES;
pub use enums::EntryKind;
pub use errors::VctrlError;
pub use traits::core::blame::Blame;
pub use traits::core::blame::BlameEntry;
pub use traits::core::config::ConfigStore;
pub use traits::core::decoder::Decoder;
pub use traits::core::diff::TreeDiffer;
pub use traits::core::encoder::Encoder;
pub use traits::core::hasher::Hasher;
pub use traits::core::index::Index;
pub use traits::core::object_store::ObjectStore;
pub use traits::core::pack::PackReader;
pub use traits::core::pack::PackWriter;
pub use traits::core::ref_store::RefStore;
pub use traits::core::reflog::ReflogStore;
pub use traits::core::remote::Remote;
pub use traits::core::revwalk::RevWalk;
pub use traits::core::signer::Signer;
pub use traits::core::transport::Transport;
pub use traits::core::verifier::Verifier;
pub use types::Blob;
pub use types::ChangeKind;
pub use types::Commit;
pub use types::CommitMeta;
pub use types::Conflict;
pub use types::FileDelta;
pub use types::Hash;
pub use types::MergeResult;
pub use types::ReflogEntry;
pub use types::Tag;
pub use types::Tree;
pub use types::TreeDelta;
pub use types::TreeEntry;
pub use types::UserID;
pub use validation::validate_hash_bytes;
pub use validation::validate_name;
pub use validation::validate_ref_name;
pub use validation::validate_tree_entry_name;

Modules§

constants
Constants related to Git object formats and operational limits.
enums
Enums for Git object types.
errors
Error types used throughout the crate.
macros
Helper macros for the crate.
traits
Traits defining repository operations.
types
Core data types for Git objects.
validation
Pure validation functions for Git inputs.

Macros§

vctrl_error_other
Constructs a VctrlError::Other from a format string and arguments.