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

Method skip_section

atomic-core/src/change/format_v3/reader/sections.rs:205–235  ·  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

203 /// - [`FormatError::InvalidSectionType`] if the section type is unknown.
204 /// - I/O errors from the underlying reader.
205 pub fn skip_section(&mut self) -> FormatResult<bool> {
206 // Ensure we have a peeked header
207 if self.peeked.is_none() && self.peek_section_type()?.is_none() {
208 return Ok(false);
209 }
210
211 let peeked = self.peeked.take().unwrap();
212
213 // Read (but don't decompress) the compressed payload
214 let mut compressed = vec![0u8; peeked.compressed_len as usize];
215 self.reader.read_exact(&mut compressed)?;
216
217 // Feed through hasher if hashed (required for correct verification)
218 if peeked.section_type.is_hashed() {
219 self.hasher.update(&peeked.header_bytes);
220 self.hasher.update(&compressed);
221 }
222
223 // Update stats
224 let header_size = peeked.header_bytes.len() as u64;
225 self.stats.sections_skipped += 1;
226 self.stats.total_compressed += peeked.compressed_len as u64;
227 self.stats.total_bytes_read += header_size + peeked.compressed_len as u64;
228 self.remaining_sections = self.remaining_sections.saturating_sub(1);
229
230 if self.remaining_sections == 0 {
231 self.sections_exhausted = true;
232 }
233
234 Ok(true)
235 }
236
237 /// Read all remaining sections, returning them as a vector.
238 ///

Calls 7

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