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

Method finalize

atomic-core/src/change/format_v3/writer/state_machine.rs:420–438  ·  view source on GitHub ↗

Finalize the change file by writing the trailer. This computes the final blake3 content hash from all hashed sections written so far, writes the 32-byte trailer, and returns the [`WriteOutcome`] containing the hash and statistics. After calling this, the writer is consumed and no more writes are possible. # Required Sections The following sections must have been written before finalizing: - Fi

(mut self)

Source from the content-addressed store, hash-verified

418 /// - [`FormatError::UnexpectedSection`] if required sections are missing.
419 /// - I/O errors from writing the trailer.
420 pub fn finalize(mut self) -> FormatResult<WriteOutcome> {
421 self.ensure_metadata_complete()?;
422
423 // Compute the final hash
424 let hash = self.hasher.finalize();
425 let content_hash = *hash.as_bytes();
426
427 // Write the trailer
428 let trailer = Trailer { content_hash };
429 trailer.write_to(self.writer)?;
430 self.stats.total_bytes_written += Trailer::SIZE as u64;
431
432 self.state = WriterState::Finalized;
433
434 Ok(WriteOutcome {
435 content_hash,
436 stats: self.stats,
437 })
438 }
439
440 // ── Low-Level: Pre-Compressed Section ──────────────────────────
441

Calls 3

as_bytesMethod · 0.45
write_toMethod · 0.45