#[non_exhaustive]pub enum PackCompression {
Ordinary,
Delta(DeltaOptions),
}Expand description
Outgoing pack compression policy. All entries use zlib level 6.
Use ordinary compression for predictable streaming scratch work. Choose delta search when smaller artifacts justify additional bounded matching and compression work; delta mode can still emit ordinary entries.
use girt::{
DeltaOptions, ObjectFormat, ObjectId, ObjectKind, PackCompression, PackObject,
PackWriteLimits, write_pack_with_compression,
};
let base: Vec<u8> = (0..4096u32)
.flat_map(|n| n.wrapping_mul(2_654_435_761).to_le_bytes())
.collect();
let mut revised = base.clone();
revised.extend_from_slice(b"new footer\n");
let inputs: Vec<_> = [&base[..], &revised[..]]
.into_iter()
.map(|data| PackObject {
id: ObjectId::for_blob(ObjectFormat::Sha1, data),
kind: ObjectKind::Blob,
data,
})
.collect();
let encode = |policy| {
let (mut pack, mut index) = (Vec::new(), Vec::new());
let report = write_pack_with_compression(
ObjectFormat::Sha1,
&inputs,
&mut pack,
&mut index,
PackWriteLimits::default(),
policy,
)?;
Ok::<_, girt::PackWriteError>((pack.len(), report))
};
let (ordinary_bytes, ordinary) = encode(PackCompression::Ordinary)?;
let (delta_bytes, delta) = encode(PackCompression::Delta(DeltaOptions::default()))?;
assert_eq!(ordinary.deltas.entries, 0);
assert_eq!(delta.deltas.entries, 1);
assert!(delta_bytes < ordinary_bytes);
assert!(delta.deltas.candidates > 0);
assert!(delta.deltas.work > 0);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Ordinary
Stream fresh ordinary entries with fixed compression scratch space (the default). Store-backed transfer writers can preserve existing compressed delta entries.
Delta(DeltaOptions)
Try bounded byte-oriented matching against earlier internal bases.
Trait Implementations§
Source§impl Clone for PackCompression
impl Clone for PackCompression
impl Copy for PackCompression
Source§impl Debug for PackCompression
impl Debug for PackCompression
Auto Trait Implementations§
impl Freeze for PackCompression
impl RefUnwindSafe for PackCompression
impl Send for PackCompression
impl Sync for PackCompression
impl Unpin for PackCompression
impl UnsafeUnpin for PackCompression
impl UnwindSafe for PackCompression
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more