Skip to content

Commit

Permalink
Make use of CompressorImpl::extra_size
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Emann committed Mar 20, 2024
1 parent 18ff70b commit 0a30154
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion crates/applesauce-core/src/compressor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ mod zlib;
pub(crate) trait CompressorImpl {
/// The offset to start data at, for the specified number of blocks
#[must_use]

fn header_size(block_count: u64) -> u64;

#[must_use]
Expand Down
9 changes: 9 additions & 0 deletions crates/applesauce-core/src/compressor/zlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ impl super::CompressorImpl for Zlib {
u32::try_from(writer.stream_position()?).map_err(|_| io::ErrorKind::InvalidInput)?;
writer.write_all(&ZLIB_TRAILER)?;

// This is logically a non-modifying operation, even if it takes &mut self, and can fail
#[allow(clippy::debug_assert_with_mut_call)]
{
debug_assert_eq!(
writer.stream_position()?,
u64::from(data_end) + Self::extra_size(block_count.into())
);
}

writer.rewind()?;
writer.write_all(&header(data_end))?;

Expand Down

0 comments on commit 0a30154

Please sign in to comment.