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)
| 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 |