refactor(wal): Consume `CrcReader` when invoking `checksum()`

pull/24376/head
Fraser Savage 2023-09-01 12:06:10 +01:00
parent 12f2716180
commit b969d07bc7
No known key found for this signature in database
GPG Key ID: DE47C33CE8C5C446
1 changed files with 3 additions and 8 deletions

View File

@ -64,7 +64,7 @@ where
.read_to_end(&mut data)
.context(UnableToReadDataSnafu)?;
let (actual_compressed_len, actual_checksum) = decompressing_read.get_mut().checksum();
let (actual_compressed_len, actual_checksum) = decompressing_read.into_inner().checksum();
ensure!(
expected_len == actual_compressed_len,
@ -118,13 +118,8 @@ impl<R> CrcReader<R> {
}
}
fn checksum(&mut self) -> (u64, u32) {
// FIXME: If rust-snappy added an `into_inner`, we should
// take `self` by value
(
std::mem::take(&mut self.bytes_seen),
std::mem::take(&mut self.hasher).finalize(),
)
fn checksum(self) -> (u64, u32) {
(self.bytes_seen, self.hasher.finalize())
}
}