MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / skip_section

Method skip_section

atomic-core/src/change/format_v3/reader/sections.rs:186–216  ·  view source on GitHub ↗

Skip the next section without decompressing it. Reads the section header and compressed payload from the source but does not decompress. The compressed bytes of hashed sections are still fed through the blake3 hasher so that verification works correctly even when sections are skipped. Returns `Ok(false)` if there are no more sections to skip. Returns `Ok(true)` if a section was successfully skip

(&mut self)

Source from the content-addressed store, hash-verified

184 /// - [`FormatError::InvalidSectionType`] if the section type is unknown.
185 /// - I/O errors from the underlying reader.
186 pub fn skip_section(&mut self) -> FormatResult<bool> {
187 // Ensure we have a peeked header
188 if self.peeked.is_none() && self.peek_section_type()?.is_none() {
189 return Ok(false);
190 }
191
192 let peeked = self.peeked.take().unwrap();
193
194 // Read (but don't decompress) the compressed payload
195 let mut compressed = vec![0u8; peeked.compressed_len as usize];
196 self.reader.read_exact(&mut compressed)?;
197
198 // Feed through hasher if hashed (required for correct verification)
199 if peeked.section_type.is_hashed() {
200 self.hasher.update(&peeked.header_bytes);
201 self.hasher.update(&compressed);
202 }
203
204 // Update stats
205 let header_size = peeked.header_bytes.len() as u64;
206 self.stats.sections_skipped += 1;
207 self.stats.total_compressed += peeked.compressed_len as u64;
208 self.stats.total_bytes_read += header_size + peeked.compressed_len as u64;
209 self.remaining_sections = self.remaining_sections.saturating_sub(1);
210
211 if self.remaining_sections == 0 {
212 self.sections_exhausted = true;
213 }
214
215 Ok(true)
216 }
217
218 /// Read all remaining sections, returning them as a vector.
219 ///

Calls 6

is_noneMethod · 0.80
peek_section_typeMethod · 0.80
updateMethod · 0.80
unwrapMethod · 0.45
is_hashedMethod · 0.45
lenMethod · 0.45