summaryrefslogtreecommitdiff
path: root/src/chunker.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-15 18:12:50 +0300
committerLars Wirzenius <liw@liw.fi>2021-09-18 17:52:36 +0300
commit6ed6b1bc75b1995a7740ff28bc26a908b91f37c8 (patch)
tree48575e9335123d5f6a228038f71565e42dbf9366 /src/chunker.rs
parentd6728974b98a821b8d633197abd97cf2fc9357f5 (diff)
downloadobnam2-6ed6b1bc75b1995a7740ff28bc26a908b91f37c8.tar.gz
refactor: define a Checksum type and use it where appropriate
This will make it harder to compare, say, a SHA-256 and a SHA3, later, when we add more checksum types. Sponsored-by: author
Diffstat (limited to 'src/chunker.rs')
-rw-r--r--src/chunker.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/chunker.rs b/src/chunker.rs
index 763c148..f096365 100644
--- a/src/chunker.rs
+++ b/src/chunker.rs
@@ -1,4 +1,4 @@
-use crate::checksummer::sha256;
+use crate::checksummer::Checksum;
use crate::chunk::DataChunk;
use crate::chunkmeta::ChunkMeta;
use std::io::prelude::*;
@@ -48,7 +48,7 @@ impl Chunker {
}
let buffer = &self.buf.as_slice()[..used];
- let hash = sha256(buffer);
+ let hash = Checksum::sha256(buffer);
let meta = ChunkMeta::new(&hash);
let chunk = DataChunk::new(buffer.to_vec(), meta);
Ok(Some(chunk))