pub trait Repository {
Show 16 methods
// Required methods
fn head(&self) -> ObjectId;
fn object_count(&self) -> usize;
// Provided methods
fn object_format(&self) -> ObjectFormat { ... }
fn head_state(&self) -> Head<'_> { ... }
fn object(&self, _index: usize) -> Option<Object<'_>> { ... }
fn object_info(&self, index: usize) -> Result<ObjectInfo> { ... }
fn read_object(
&self,
index: usize,
offset: u64,
storage: &mut [u8],
) -> Result<usize> { ... }
fn object_id(&self, index: usize) -> Option<ObjectId> { ... }
fn head_ref(&self) -> &str { ... }
fn reference_count(&self) -> usize { ... }
fn reference_name(&self, index: usize) -> Option<&str> { ... }
fn reference_id(&self, index: usize) -> Option<ObjectId> { ... }
fn reference_symbolic_target(&self, _index: usize) -> Option<&str> { ... }
fn reference_peeled(&self, _index: usize) -> Option<ObjectId> { ... }
fn find(&self, id: ObjectId) -> Option<Object<'_>> { ... }
fn find_index(&self, id: ObjectId) -> Option<usize> { ... }
}Expand description
A stable snapshot containing the union reachable from HEAD and advertised refs.
A resolved HEAD and branch tips must refer to commits. An unborn HEAD has no
commit, but other branches or tags may still exist.
Objects must stay stable throughout a request
and across discovery/fetch requests for the same repository URL. Enumeration
must be complete and deterministic; each index below object_count must exist.
Implementations may borrow memory or implement object_info/read_object
for file-backed or generated bodies. Their lengths and IDs must be exact.
Ref names must be
valid, unique, byte-sorted, and include the symbolic HEAD branch, if resolved.
Names must fit ref_name_limit(object_format()); symbolic and unborn targets
must fit head_ref_limit and unborn_ref_limit for the repository format.
Required Methods§
Sourcefn head(&self) -> ObjectId
fn head(&self) -> ObjectId
Resolved commit ID, or the all-zero sentinel for an unborn HEAD.
Use head_state().id() when absence needs to be distinguished.
fn object_count(&self) -> usize
Provided Methods§
Sourcefn object_format(&self) -> ObjectFormat
fn object_format(&self) -> ObjectFormat
Fixed for the entire repository, including unborn HEAD. Defaults to
SHA-1; SHA-256 providers must override this independently of object_id.
fn head_state(&self) -> Head<'_>
Sourcefn object(&self, _index: usize) -> Option<Object<'_>>
fn object(&self, _index: usize) -> Option<Object<'_>>
Optional borrowed-body fast path. Streaming providers can leave this as
None and implement object_info, read_object, and object_id instead.
fn object_info(&self, index: usize) -> Result<ObjectInfo>
Sourcefn read_object(
&self,
index: usize,
offset: u64,
storage: &mut [u8],
) -> Result<usize>
fn read_object( &self, index: usize, offset: u64, storage: &mut [u8], ) -> Result<usize>
Read at most storage.len() body bytes starting at a byte offset.
Short reads are allowed. Return zero only at EOF or for empty storage.
Calls must be independent of earlier reads, enabling interleaved readers
and retries. Errors may modify storage but must not change the object.
Sourcefn object_id(&self, index: usize) -> Option<ObjectId>
fn object_id(&self, index: usize) -> Option<ObjectId>
Return an object’s ID. Streaming providers must supply precomputed IDs;
ObjectHasher computes them incrementally with caller-owned scratch.
fn head_ref(&self) -> &str
fn reference_count(&self) -> usize
fn reference_name(&self, index: usize) -> Option<&str>
Sourcefn reference_id(&self, index: usize) -> Option<ObjectId>
fn reference_id(&self, index: usize) -> Option<ObjectId>
Defaults preserve snapshot commit aliases. Override for independent tips.
fn reference_symbolic_target(&self, _index: usize) -> Option<&str>
fn reference_peeled(&self, _index: usize) -> Option<ObjectId>
fn find(&self, id: ObjectId) -> Option<Object<'_>>
Sourcefn find_index(&self, id: ObjectId) -> Option<usize>
fn find_index(&self, id: ObjectId) -> Option<usize>
Lookup without requiring a borrowed body. Metadata providers can index it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".