Skip to main content

FetchPack

Struct FetchPack 

Source
pub struct FetchPack<'a> { /* private fields */ }
Expand description

The client side of git-upload-pack, configured for one fetch.

Shaped like UploadPack on purpose: a constructor taking the two things that cannot be defaulted, with_* for the rest, and one method that runs the whole conversation over a &mut dyn BufRead / &mut dyn Write pair.

§The transport pair is two arguments, not an IoPair

gunnar-client has a 57-line IoPair<R, W> and a Transport trait, and copying either here would have been a second seam for the same idea. This crate’s seam is already the pair: every entry point in upload_pack and receive_pack takes &mut dyn BufRead and &mut dyn Write and cannot tell an SSH channel from a pipe from a Vec<u8>. A caller holding an IoPair calls io() and passes the two halves; a caller holding a russh channel passes the bridge gunnar-server already builds for upload_pack.

Implementations§

Source§

impl<'a> FetchPack<'a>

Source

pub fn new( hash_kind: Kind, wanted: &'a dyn Fn(&str) -> bool, local: &'a dyn LocalRefs, ) -> Self

A fetch at hash_kind, taking the references wanted accepts and offering everything local holds as haves.

Source

pub fn with_ceiling(self, ceiling: PackCeiling) -> Self

Hold the packfile to a byte ceiling, exactly as a push is held to one: the stream is counted as the ingest takes it, cut the moment it passes PackCeiling::bytes — the ingest is handed at most the ceiling and one byte — and the fetch then fails with Error::OverCeiling carrying the ceiling’s own refusal. A ledger on the ceiling is asked chunk by chunk, so a fetch and a push into one namespace share its room rather than each spending it.

This is how a mirror into a namespace with a storage cap stops cleanly AT the cap when its upstream turns out bigger than the room it has: the git protocol says nothing of a pack’s size before it arrives, so the only place the answer can be enforced is here, while it streams.

Source

pub fn with_agent(self, agent: String) -> Self

Announce a different agent= string.

Source

pub fn with_progress(self, progress: &'a dyn FetchProgress) -> Self

Report the declared object count and the streaming byte count as they become known.

Source

pub fn hash_kind(&self) -> Kind

The hash kind this client speaks, and the only object-format it will accept from a remote.

Source

pub fn fetch( &self, ingest: &dyn PackIngest, input: &mut dyn BufRead, output: &mut dyn Write, ) -> Result<FetchReport>

Run the whole fetch.

Advertisement, ls-refs, want selection, negotiation, and the packfile streamed into ingest. Returns the plan; applying the references is the caller’s job (module doc).

§What it refuses, and why each refusal is not a warning
  • a remote whose object-format is not this client’s, and the alternative is an empty answer that reads as success;
  • a packfile section that ends before its flush-pkt — a mirror that accepted half a pack would then apply references pointing at objects it does not hold;
  • a pack whose header declares one object count and whose ingest reports another. An indexer that stops early and reports what it managed is indistinguishable from a complete transfer at every other seam; the declared count is the only independent statement of how many objects were supposed to arrive, and comparing them costs one u32.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for FetchPack<'a>

§

impl<'a> !Send for FetchPack<'a>

§

impl<'a> !Sync for FetchPack<'a>

§

impl<'a> !UnwindSafe for FetchPack<'a>

§

impl<'a> Freeze for FetchPack<'a>

§

impl<'a> Unpin for FetchPack<'a>

§

impl<'a> UnsafeUnpin for FetchPack<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more