Skip to main content

Crate shardline_protocol_adapters

Crate shardline_protocol_adapters 

Source
Expand description

Shared protocol adapters for Git LFS, Bazel HTTP cache, and related object-key mapping.

This crate owns the small, self-contained functions that map protocol identifiers to validated shardline_storage::ObjectKey values. It avoids pulling in heavy server dependencies such as axum or sqlx.

§Quick start

Everything here is pure. The most common task is mapping an LFS object ID to a storage key:

use shardline_protocol_adapters::{LfsOperation, TransferAdapter, lfs_object_key};
use shardline_server_core::AuthorizedRepository;

let oid = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
let key = lfs_object_key(oid, &AuthorizedRepository::anonymous_full_access())?;
assert!(key.as_str().starts_with("protocols/lfs/global/objects/"));
assert!(key.as_str().ends_with(oid));

// Malformed OIDs are rejected instead of being stored under a bad key.
assert!(
    lfs_object_key("not-a-valid-sha256", &AuthorizedRepository::anonymous_full_access())
        .is_err()
);

// Batch operations and transfer adapters round-trip through their wire names.
assert_eq!("download".parse(), Ok(LfsOperation::Download));
assert_eq!(TransferAdapter::Xet.as_str(), "xet");

See also bazel_cache_object_key for the Bazel HTTP cache mapping and scope_namespace for repository-scoped key prefixes.

Modules§

cas_headers
Xet CAS transfer header names used in LFS batch responses and provider token-issuance flows. These tell the git-xet transfer agent where and how to connect to the content-addressed storage layer.

Structs§

LfsBatchRequest
LfsBatchResponse
LfsObjectError
LfsObjectRequest
LfsObjectResponse

Enums§

BazelCacheKind
LfsOperation
LFS batch operation identifiers.
LfsValidationError
Well-known LFS validation error messages.
ProtocolError
Protocol adapter error type.
TransferAdapter
LFS transfer adapter identifiers negotiated in the batch API.

Constants§

LFS_CONTENT_TYPE

Functions§

bazel_cache_object_key
Returns the storage object key for a Bazel cache entry.
lfs_object_key
Returns the storage object key for an LFS object.
object_key
Maps a raw string to a validated ObjectKey.
scope_namespace
Produces a deterministic namespace prefix for a repository scope.
validate_content_hash
Validates that value is exactly 64 lowercase hexadecimal characters.