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>
impl<'a> FetchPack<'a>
Sourcepub fn new(
hash_kind: Kind,
wanted: &'a dyn Fn(&str) -> bool,
local: &'a dyn LocalRefs,
) -> Self
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.
Sourcepub fn with_ceiling(self, ceiling: PackCeiling) -> Self
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.
Sourcepub fn with_agent(self, agent: String) -> Self
pub fn with_agent(self, agent: String) -> Self
Announce a different agent= string.
Sourcepub fn with_progress(self, progress: &'a dyn FetchProgress) -> Self
pub fn with_progress(self, progress: &'a dyn FetchProgress) -> Self
Report the declared object count and the streaming byte count as they become known.
Sourcepub fn hash_kind(&self) -> Kind
pub fn hash_kind(&self) -> Kind
The hash kind this client speaks, and the only object-format it will
accept from a remote.
Sourcepub fn fetch(
&self,
ingest: &dyn PackIngest,
input: &mut dyn BufRead,
output: &mut dyn Write,
) -> Result<FetchReport>
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-formatis not this client’s, and the alternative is an empty answer that reads as success; - a
packfilesection 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.