Skip to main content

Module remote

Module remote 

Source
Expand description

High-level handle to a git-remote-object-store repository.

§Entry point

Remote is the primary library entry point for external consumers. It wraps an ObjectStore and the repository-level key prefix from the RemoteUrl, so callers never need to track the prefix separately or know the internal key layout.

§On-bucket key layout

Objects are stored under <prefix>/<suffix> (where <prefix> is the path component of the URL and may be empty for bucket-root repositories):

SuffixPurpose
HEADRef pointer for the default branch
refs/heads/<branch>/<sha>.bundleGit bundle for a branch commit
refs/heads/<branch>/LOCK#.lockPer-ref push-lock file
refs/heads/<branch>/PROTECTED#Per-ref branch-protection sentinel
lfs/<oid>Git LFS object

Use Remote::key to build correctly-prefixed keys, then call methods on Remote::store directly for operations not covered by the helper methods.

§Example

use git_remote_object_store::Remote;

let remote = Remote::connect("s3+https://my-bucket.s3.us-east-1.amazonaws.com/my-repo").await?;

// Read the HEAD ref
let head = remote.get_head().await?;
println!("{}", String::from_utf8_lossy(&head));

// List all objects on a branch
let metas = remote.list("refs/heads/main/").await?;
for meta in metas {
    println!("{} ({} bytes)", meta.key, meta.size);
}

// Same data via direct store access, for operations not covered by
// the helper methods (custom keys, raw puts, conditional writes).
let same_head = remote.store().get_bytes(&remote.key("HEAD")).await?;
assert_eq!(head, same_head);

Structs§

Remote
A handle to a git-remote-object-store repository in a cloud backend.

Enums§

RemoteError
Error returned by Remote::connect.