Skip to main content

Publication

Struct Publication 

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

Source

pub fn new( repository: &'a R, entries: &'a mut [IndexEntry], scratch: &mut [u8], loose: LooseObjects, ) -> Result<Self>

Source

pub fn checksum(&self) -> ObjectId

Source

pub fn pack_size(&self) -> u64

Source

pub fn index_size(&self) -> u64

Source

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.

Source

pub fn serve( &self, request: Request<'_>, scratch: &mut [u8], output: &mut impl Write, ) -> Result<Option<Response>>

Buffered-writer convenience over the same independent pull cursor. On a sink/provider error all output is invalid. No bytes are written on None.

Auto Trait Implementations§

§

impl<'a, R> Freeze for Publication<'a, R>
where &'a R: Freeze,

§

impl<'a, R> RefUnwindSafe for Publication<'a, R>

§

impl<'a, R> Send for Publication<'a, R>
where &'a R: Send,

§

impl<'a, R> Sync for Publication<'a, R>
where &'a R: Sync,

§

impl<'a, R> Unpin for Publication<'a, R>
where &'a R: Unpin,

§

impl<'a, R> UnsafeUnpin for Publication<'a, R>

§

impl<'a, R> UnwindSafe for Publication<'a, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.