libvctrl

libvctrl

A precision toolkit for building custom version control systems in Rust.

libvctrl is a workspace of six crates that together provide:

The workspace is designed to be layered, auditable, and usable either as a complete batteries-included VCS SDK or as a set of focused, standalone libraries.


Workspace at a glance

Crate Version Role MSRV License
libvctrl 2.2.0 Facade: re-exports the full SDK 1.96.0 MIT
libvctrl_handler 5.2.0 Contracts: traits, immutable types, limits, validation 1.96.0 MIT
libvctrl_core 3.2.0 Reference implementations: codec, builders, stores, hasher 1.96.0 MIT
libvctrl_sha512 3.2.0 SHA-512, HMAC-SHA512, HKDF-SHA512, optional SHA-384 1.96.0 ISC
libvctrl_plumbing 0.2.0 Command-level VCS operations built on libvctrl_core 1.96.0 MIT
libvctrl_porcelain 0.1.0 High-level, user-facing VCS operations 1.96.0 MIT

All crates share Rust edition 2024 and are tested against Rust 1.96.0.


Architecture

The dependency flow is strictly one-way:

flowchart LR
    H[libvctrl_handler<br/>contracts] --> C[libvctrl_core<br/>reference impl]
    S[libvctrl_sha512<br/>crypto] --> C
    C --> PL[libvctrl_plumbing]
    C --> PO[libvctrl_porcelain]
    H --> F[libvctrl<br/>facade]
    C --> F
    S --> F

Features


Quick start

Add the facade to your Cargo.toml:

[dependencies]
libvctrl = "2.2"

Build, encode, hash, store, and decode a blob:

use std::io::Cursor;
use libvctrl::{
    Blob, BinaryDecoder, BinaryEncoder, Decoder, Encoder, Hasher, MemoryStore,
    ObjectStore, Sha512Hasher, VctrlError,
};

fn main() -> Result<(), VctrlError> {
    // 1. Create a validated blob.
    let blob = Blob::new(b"hello world".to_vec())?;

    // 2. Encode it into deterministic bytes.
    let mut encoded = Vec::new();
    BinaryEncoder.encode_blob(&blob, &mut encoded)?;

    // 3. Hash the encoded bytes to get a 64-byte content address.
    let hash = Sha512Hasher.hash(&mut encoded.as_slice())?;

    // 4. Store the object in memory.
    let mut store = MemoryStore::new();
    store.put(&hash, &encoded)?;

    // 5. Retrieve and decode it back.
    let reader = store.get(&hash)?;
    let decoded = BinaryDecoder.decode_blob(reader)?;

    assert_eq!(decoded, blob);
    Ok(())
}

Using a focused crate

If you only need contracts, crypto, or the reference implementation, depend on the individual crate instead of the facade:

[dependencies]
libvctrl_handler = "5.2"     # contracts only
libvctrl_core = "3.2"        # codec, builders, stores, hasher adapter
libvctrl_sha512 = "3.2"      # raw SHA-512/HMAC/HKDF

The crypto crate supports feature flags for SHA-384 and size optimisation:

# Minimal SHA-512 only
libvctrl_sha512 = { version = "3.2", default-features = false }

# Size-optimised SHA-512
libvctrl_sha512 = { version = "3.2", default-features = false, features = ["opt_size"] }

Repository layout

libvctrl/
├── Cargo.toml
├── rust-toolchain.toml
├── README.md
├── libvctrl/
├── libvctrl_handler/
├── libvctrl_core/
├── libvctrl_sha512/
├── libvctrl_plumbing/
└── libvctrl_porcelain/

Each crate has its own README.md and Cargo.toml.


Testing, linting, and documentation

Run the full workspace test suite:

cargo test --workspace --all-targets --all-features

Run formatting checks:

cargo fmt --all -- --check

Run Clippy with warnings denied:

cargo clippy --workspace --all-targets --all-features -- -D warnings

Build documentation:

cargo doc --workspace --no-deps

Run benchmarks for crypto and handler crates:

cargo bench -p libvctrl_sha512
cargo bench -p libvctrl_handler

Security and safety

The workspace enforces:

No formal security audit has been performed. Use at your own risk in production.


Contributing

Contributions are welcome. See CONTRIBUTING.md for guidelines.

General rules:


License

The workspace is licensed under the MIT License, except for libvctrl_sha512, which is licensed under the ISC License.

See the individual crate LICENSE files for full text.