pub struct Reader<'a> { /* private fields */ }Expand description
Reader over one complete downloaded pack. Construction verifies its
framing and hash; entries are then inflated/length-checked one at a time.
Each call borrows caller staging storage and a reusable 32 KiB zlib window.
Call finish (or read through None) to verify count and exact pack closure.
Forward reference deltas require host base lookup; thin-pack bases may be
supplied as ResolvedObject::external. No pack-index file parser is implied.
Implementations§
Source§impl<'a> Reader<'a>
impl<'a> Reader<'a>
pub fn new(pack: &'a [u8]) -> Result<Reader<'a>, Error>
pub fn new_with_format( pack: &'a [u8], format: ObjectFormat, ) -> Result<Reader<'a>, Error>
pub fn object_count(&self) -> u32
pub fn remaining(&self) -> u32
pub fn position(&self) -> u64
pub fn pack_id(&self) -> ObjectId
Sourcepub fn next_entry_size(&self) -> Result<Option<u64>, Error>
pub fn next_entry_size(&self) -> Result<Option<u64>, Error>
Inspect the next entry’s declared inflated body/instruction size without
advancing. Hosts must apply their own budget before allocating storage.
The declaration is checked against the actual stream by read_entry.
Sourcepub fn read_entry<'out>(
&mut self,
output: &'out mut [u8],
window: &mut [u8; 32768],
limits: InflateLimits,
) -> Result<Option<Entry<'out>>, Error>
pub fn read_entry<'out>( &mut self, output: &'out mut [u8], window: &mut [u8; 32768], limits: InflateLimits, ) -> Result<Option<Entry<'out>>, Error>
Read the next entry. Declared size is the inflated body/instruction size. A staging-capacity or budget error preserves the cursor for retry. Other errors also preserve the cursor; staging bytes may have changed.