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(bytes: &[u8], format: ObjectFormat) -> Result<Self>
pub fn parse_bundle(bundle: &Bundle) -> Result<Self>
pub fn index_pack(bytes: &[u8], format: ObjectFormat) -> Result<PackWrite>
pub fn parse_thin<F>( bytes: &[u8], format: ObjectFormat, external_base: F, ) -> 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 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.