pub struct PackEncoder {
pub disable_prefilter: bool,
/* private fields */
}Expand description
Stateful encoder for one Git pack stream.
A PackEncoder is single-use. It tracks the current pack offset and checksum while encoded
chunks are sent to pack_sender. If idx_sender is present, index records are accumulated and
can be emitted with PackEncoder::encode_idx_file after pack encoding finishes.
Fields§
§disable_prefilter: boolSkip the cheap similarity pre-filter and score every otherwise valid window candidate.
This can improve compression at the cost of more delta computation. The default Rabin path disables the pre-filter to follow Git’s candidate-search behavior.
Implementations§
Source§impl PackEncoder
impl PackEncoder
Sourcepub async fn parallel_encode(
&mut self,
entry_rx: Receiver<MetaAttached<Entry, EntryMeta>>,
) -> Result<(), GitError>
pub async fn parallel_encode( &mut self, entry_rx: Receiver<MetaAttached<Entry, EntryMeta>>, ) -> Result<(), GitError>
Encode independent objects in parallel without delta compression.
Input is read in bounded batches, and Rayon performs each object’s header construction and zlib compression concurrently. Rayon collection preserves input order, after which chunks are written serially so pack offsets and the running checksum remain correct.
This path is valid only when window_size == 0.
Source§impl PackEncoder
impl PackEncoder
Sourcepub fn new(
object_number: usize,
window_size: usize,
sender: Sender<Vec<u8>>,
) -> Self
pub fn new( object_number: usize, window_size: usize, sender: Sender<Vec<u8>>, ) -> Self
Create an encoder that streams pack bytes but does not build an index.
Sourcepub fn new_with_idx(
object_number: usize,
window_size: usize,
pack_sender: Sender<Vec<u8>>,
idx_sender: Sender<Vec<u8>>,
) -> Self
pub fn new_with_idx( object_number: usize, window_size: usize, pack_sender: Sender<Vec<u8>>, idx_sender: Sender<Vec<u8>>, ) -> Self
Create an encoder that streams pack bytes and retains metadata for a later .idx stream.
Sourcepub fn drop_sender(&mut self)
pub fn drop_sender(&mut self)
Close the pack output stream by dropping the encoder’s final sender.
Sourcepub async fn send_data(&mut self, data: Vec<u8>)
pub async fn send_data(&mut self, data: Vec<u8>)
Send one already-encoded byte chunk to the pack consumer.
Sourcepub fn get_hash(&self) -> Option<ObjectHash>
pub fn get_hash(&self) -> Option<ObjectHash>
Return the pack checksum after encoding has completed.
Sourcepub async fn encode(
&mut self,
entry_rx: Receiver<MetaAttached<Entry, EntryMeta>>,
) -> Result<(), GitError>
pub async fn encode( &mut self, entry_rx: Receiver<MetaAttached<Entry, EntryMeta>>, ) -> Result<(), GitError>
Consume an entry stream and emit one complete pack stream.
With window_size == 0, entries are independently zlib-compressed in parallel. With a
non-zero window, entries are collected, sorted for delta locality, and passed through
sliding-window base selection.
When diff_rabin is enabled, the default delta engine is Rabin and all otherwise valid
candidates are scored. Without that feature, the Myers/Patience engine is used after the
configured similarity pre-filter.
Sourcepub async fn encode_with_zstdelta(
&mut self,
entry_rx: Receiver<MetaAttached<Entry, EntryMeta>>,
) -> Result<(), GitError>
pub async fn encode_with_zstdelta( &mut self, entry_rx: Receiver<MetaAttached<Entry, EntryMeta>>, ) -> Result<(), GitError>
Encode with zstdelta payloads while retaining the same sorting and base-selection pipeline.
Sourcepub async fn encode_async(
self,
rx: Receiver<MetaAttached<Entry, EntryMeta>>,
) -> Result<JoinHandle<()>, GitError>
pub async fn encode_async( self, rx: Receiver<MetaAttached<Entry, EntryMeta>>, ) -> Result<JoinHandle<()>, GitError>
Spawn pack encoding as a Tokio task and return its join handle.
This consumes the encoder so the spawned task owns all channel senders and state. The task
chooses the same zero-window versus delta-window path as PackEncoder::encode.
Encoding errors currently panic inside the spawned task and are therefore reported as a
JoinError when the returned handle is awaited.
Sourcepub async fn encode_async_with_zstdelta(
self,
rx: Receiver<MetaAttached<Entry, EntryMeta>>,
) -> Result<JoinHandle<()>, GitError>
pub async fn encode_async_with_zstdelta( self, rx: Receiver<MetaAttached<Entry, EntryMeta>>, ) -> Result<JoinHandle<()>, GitError>
Spawn zstdelta pack encoding as a Tokio task.
zstdelta always uses the windowed path because independent encoding has no base from which to produce a delta.
Sourcepub async fn encode_idx_file(&mut self) -> Result<(), GitError>
pub async fn encode_idx_file(&mut self) -> Result<(), GitError>
Emit the .idx stream after the pack has been finalized.
Pack encoding must run first because the index trailer contains the pack checksum and each record needs its final absolute pack offset.
Auto Trait Implementations§
impl Freeze for PackEncoder
impl RefUnwindSafe for PackEncoder
impl Send for PackEncoder
impl Sync for PackEncoder
impl Unpin for PackEncoder
impl UnsafeUnpin for PackEncoder
impl UnwindSafe for PackEncoder
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.