pub struct Publication<'a, R> { /* private fields */ }Expand description
One complete stored pack and its matching index, generated from an immutable repository. Preparation encodes every object once into a counting sink and retains one caller-owned metadata slot per object, rather than pack bytes. Downloads replay that deterministic encoding; index downloads use the retained metadata and never read object bodies. Separate response cursors can overlap.
The repository must satisfy Repository’s accurate-ID, complete visible graph
and stability contracts. Use ValidatedRepository for untrusted providers.
Keep refs, HEAD, object enumeration, metadata and bodies unchanged throughout
this value’s life AND the lifetime of its published URL. A new repository
requires a new publication/URL; replacing a live URL breaks dumb HTTP retries.
Preparation failures publish nothing. A failed response must be discarded or
its transport aborted. This API publishes the stored encoder’s full graph;
arbitrary compressed/delta input and selected-pack reuse are separate APIs.
Implementations§
Source§impl<'a, R: Repository> Publication<'a, R>
impl<'a, R: Repository> Publication<'a, R>
pub fn new( repository: &'a R, entries: &'a mut [IndexEntry], scratch: &mut [u8], loose: LooseObjects, ) -> Result<Self>
pub fn checksum(&self) -> ObjectId
pub fn pack_size(&self) -> u64
pub fn index_size(&self) -> u64
Sourcepub fn prepare(
&self,
request: Request<'_>,
) -> Result<Option<PublishedResponse<'_, R>>>
pub fn prepare( &self, request: Request<'_>, ) -> Result<Option<PublishedResponse<'_, R>>>
Dispatch publication routes before ordinary smart/loose serving. None
means the caller must use its normal handler (including authorization).
Shared route validation applies even to fallthrough requests. Discovery
and refs still come from this exact immutable repository via that handler.
Headers may include Content-Length from the cursor. Keep mutable refs and
discovery uncached; immutable pack/index bytes may be cached by the host.