Skip to main content

Repository

Trait Repository 

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

Source

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.

Source

fn object_count(&self) -> usize

Provided Methods§

Source

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.

Source

fn head_state(&self) -> Head<'_>

Source

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.

Source

fn object_info(&self, index: usize) -> Result<ObjectInfo>

Source

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.

Source

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.

Source

fn head_ref(&self) -> &str

Source

fn reference_count(&self) -> usize

Source

fn reference_name(&self, index: usize) -> Option<&str>

Source

fn reference_id(&self, index: usize) -> Option<ObjectId>

Defaults preserve snapshot commit aliases. Override for independent tips.

Source

fn reference_symbolic_target(&self, _index: usize) -> Option<&str>

Source

fn reference_peeled(&self, _index: usize) -> Option<ObjectId>

Source

fn find(&self, id: ObjectId) -> Option<Object<'_>>

Source

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".

Implementors§