pub struct PackFile {
pub version: u32,
pub entries: Vec<PackObject>,
pub checksum: ObjectId,
}Fields§
§version: u32§entries: Vec<PackObject>§checksum: ObjectIdImplementations§
Source§impl PackFile
impl PackFile
pub fn parse_sha1(bytes: &[u8]) -> Result<Self>
pub fn parse_sha1_with_limits( bytes: &[u8], limits: PackReadLimits, ) -> Result<Self>
pub fn parse(bytes: &[u8], format: ObjectFormat) -> Result<Self>
Sourcepub fn parse_with_limits(
bytes: &[u8],
format: ObjectFormat,
limits: PackReadLimits,
) -> Result<Self>
pub fn parse_with_limits( bytes: &[u8], format: ObjectFormat, limits: PackReadLimits, ) -> Result<Self>
Parse and resolve a complete pack with explicit read limits.
pub fn parse_bundle(bundle: &Bundle) -> Result<Self>
pub fn parse_bundle_with_limits( bundle: &Bundle, limits: PackReadLimits, ) -> Result<Self>
pub fn index_pack(bytes: &[u8], format: ObjectFormat) -> Result<PackWrite>
pub fn index_pack_with_limits( bytes: &[u8], format: ObjectFormat, limits: PackReadLimits, ) -> Result<PackWrite>
pub fn parse_thin<F>( bytes: &[u8], format: ObjectFormat, external_base: F, ) -> Result<Self>
pub fn parse_thin_with_limits<F>( bytes: &[u8], format: ObjectFormat, external_base: F, limits: PackReadLimits, ) -> Result<Self>
Sourcepub fn verify_pack_stats(
bytes: &[u8],
format: ObjectFormat,
) -> Result<PackVerifyStats>
pub fn verify_pack_stats( bytes: &[u8], format: ObjectFormat, ) -> Result<PackVerifyStats>
Walk the pack and produce per-object statistics matching the output of
git verify-pack -v / git index-pack --verify-stat.
Objects are returned in pack offset order (the order git verify-pack -v
prints them). Each entry carries the resolved object id, type and size,
the in-pack byte span (size_in_pack = the offset delta to the next
object, or to the trailing checksum for the last object), the in-pack
offset, the delta chain depth (0 for undeltified objects), and — for
deltas — the object id of the immediate base (which may itself be a
delta). This mirrors builtin/index-pack.c’s show_pack_info.
pub fn verify_pack_stats_with_limits( bytes: &[u8], format: ObjectFormat, limits: PackReadLimits, ) -> Result<PackVerifyStats>
Source§impl PackFile
impl PackFile
pub fn write_undeltified_sha1<T>(objects: &[T]) -> Result<PackWrite>where
T: Borrow<EncodedObject>,
Sourcepub fn write_undeltified<T>(
objects: &[T],
format: ObjectFormat,
) -> Result<PackWrite>where
T: Borrow<EncodedObject>,
pub fn write_undeltified<T>(
objects: &[T],
format: ObjectFormat,
) -> Result<PackWrite>where
T: Borrow<EncodedObject>,
Write a pack with every object stored undeltified (no delta entries).
This is the simple, self-contained encoding; objects appear in the given
order. For smaller output that exploits similarity between objects, use
PackFile::write_packed.
Sourcepub fn write_packed<T>(objects: &[T], format: ObjectFormat) -> Result<PackWrite>where
T: Borrow<EncodedObject>,
pub fn write_packed<T>(objects: &[T], format: ObjectFormat) -> Result<PackWrite>where
T: Borrow<EncodedObject>,
Write a pack using sliding-window delta selection with git-compatible
defaults (window DEFAULT_PACK_WINDOW, depth DEFAULT_PACK_DEPTH,
ofs-deltas, self-contained).
Objects are grouped by type and ordered for good deltas, then each is
compared against a window of previously emitted candidates; the smallest
acceptable delta is kept, otherwise the object is stored undeltified. The
result round-trips through PackFile::parse.
Sourcepub fn write_packed_with_options<T>(
objects: &[T],
format: ObjectFormat,
options: &PackWriteOptions,
) -> Result<PackWrite>where
T: Borrow<EncodedObject>,
pub fn write_packed_with_options<T>(
objects: &[T],
format: ObjectFormat,
options: &PackWriteOptions,
) -> Result<PackWrite>where
T: Borrow<EncodedObject>,
Like PackFile::write_packed but with caller-supplied
PackWriteOptions (window, depth, base-reference style, and optional
external thin bases).
Sourcepub fn write_packed_with_known_ids(
inputs: &[PackInput<'_>],
format: ObjectFormat,
) -> Result<PackWrite>
pub fn write_packed_with_known_ids( inputs: &[PackInput<'_>], format: ObjectFormat, ) -> Result<PackWrite>
Like PackFile::write_packed, but uses caller-supplied object ids
instead of re-hashing each object before pack planning.
This is intended for object-database paths that reached each object by
its id and already trust that id/object mapping. The function validates
id formats and duplicate ids, but it does not re-hash object bodies; use
PackFile::write_packed when the ids are not already known to be
canonical.
Sourcepub fn write_packed_with_known_ids_and_options(
inputs: &[PackInput<'_>],
format: ObjectFormat,
options: &PackWriteOptions,
) -> Result<PackWrite>
pub fn write_packed_with_known_ids_and_options( inputs: &[PackInput<'_>], format: ObjectFormat, options: &PackWriteOptions, ) -> Result<PackWrite>
Like PackFile::write_packed_with_known_ids but with caller-supplied
PackWriteOptions.
pub fn write_packed_with_known_ids_to_writer<W>(
inputs: &[PackInput<'_>],
format: ObjectFormat,
options: &PackWriteOptions,
writer: &mut W,
) -> Result<PackWriteSummary>where
W: Write,
Sourcepub fn write_thin<T>(
objects: &[T],
format: ObjectFormat,
external_bases: HashMap<ObjectId, EncodedObject>,
) -> Result<PackWrite>where
T: Borrow<EncodedObject>,
pub fn write_thin<T>(
objects: &[T],
format: ObjectFormat,
external_bases: HashMap<ObjectId, EncodedObject>,
) -> Result<PackWrite>where
T: Borrow<EncodedObject>,
Write a thin pack: objects may be deltified against external_bases
that are not included in the pack, referenced by ref-delta to their
object id.
The receiver must already have (or otherwise obtain) those base objects
and resolve the pack with PackFile::parse_thin. Window and depth use
the defaults; pass options via PackFile::write_packed_with_options
with PackWriteOptions::with_thin_bases for finer control.
pub fn write_undeltified_from_source_to_writer<W, I, F>(
selected_objects: I,
object_count: u32,
format: ObjectFormat,
options: &PackWriteOptions,
limits: PackWriteLimits,
read_object: F,
writer: &mut W,
) -> Result<PackWriteSummary>where
W: Write,
I: IntoIterator<Item = ObjectId>,
F: FnMut(&ObjectId) -> Result<Arc<EncodedObject>>,
Sourcepub fn write_undeltified_from_source_to_writer_with_cancel<W, I, F>(
selected_objects: I,
object_count: u32,
format: ObjectFormat,
options: &PackWriteOptions,
limits: PackWriteLimits,
read_object: F,
writer: &mut W,
cancel: CancelFlag<'_>,
) -> Result<PackWriteSummary>where
W: Write,
I: IntoIterator<Item = ObjectId>,
F: FnMut(&ObjectId) -> Result<Arc<EncodedObject>>,
pub fn write_undeltified_from_source_to_writer_with_cancel<W, I, F>(
selected_objects: I,
object_count: u32,
format: ObjectFormat,
options: &PackWriteOptions,
limits: PackWriteLimits,
read_object: F,
writer: &mut W,
cancel: CancelFlag<'_>,
) -> Result<PackWriteSummary>where
W: Write,
I: IntoIterator<Item = ObjectId>,
F: FnMut(&ObjectId) -> Result<Arc<EncodedObject>>,
Undeltified pack write from a one-shot object-id iterator.
object_count is written into the pack header. Yielding fewer or more
ids is GitError::CountMismatch and never a successful pack.
Repeated ids are rejected as they are consumed. Compression windows are
admitted by PackWriteLimits. Polls cancel between windows and
while filling a window.
pub fn write_packed_from_source_to_writer<W, I, F>(
selected_objects: I,
object_count: u32,
format: ObjectFormat,
options: &PackWriteOptions,
limits: PackWriteLimits,
read_object: F,
writer: &mut W,
) -> Result<PackWriteSummary>where
W: Write,
I: IntoIterator<Item = ObjectId>,
F: FnMut(&ObjectId) -> Result<Arc<EncodedObject>>,
Sourcepub fn write_packed_from_source_to_writer_with_cancel<W, I, F>(
selected_objects: I,
object_count: u32,
format: ObjectFormat,
options: &PackWriteOptions,
limits: PackWriteLimits,
read_object: F,
writer: &mut W,
cancel: CancelFlag<'_>,
) -> Result<PackWriteSummary>where
W: Write,
I: IntoIterator<Item = ObjectId>,
F: FnMut(&ObjectId) -> Result<Arc<EncodedObject>>,
pub fn write_packed_from_source_to_writer_with_cancel<W, I, F>(
selected_objects: I,
object_count: u32,
format: ObjectFormat,
options: &PackWriteOptions,
limits: PackWriteLimits,
read_object: F,
writer: &mut W,
cancel: CancelFlag<'_>,
) -> Result<PackWriteSummary>where
W: Write,
I: IntoIterator<Item = ObjectId>,
F: FnMut(&ObjectId) -> Result<Arc<EncodedObject>>,
Streaming deltified pack write from a one-shot object-id iterator.
Separates the pack header’s required object_count from enumeration:
selected_objects is consumed once and does not need ExactSizeIterator,
Clone, or collection conversion. Yielding fewer or more ids than
object_count is GitError::CountMismatch and never a successful pack.
Compression windows are admitted by PackWriteLimits, not a fixed
object count. A single object larger than the ordinary working-set
budget is written as a one-object quantum when it still fits
PackWriteLimits::decoded_object; otherwise it is a typed
GitError::ResourceLimit. Delta-base retention is charged to
PackWriteLimits::delta_base. A leftover lookahead object that does
not fit the current window is charged against the working-set peak.
Repeated ids are rejected as they are consumed. Output-writer
backpressure and read_object failures stop further enumeration. Polls
cancel between windows and while filling a window, and returns
GitError::Cancelled when the flag trips.