From 6ed6b1bc75b1995a7740ff28bc26a908b91f37c8 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 15 Sep 2021 18:12:50 +0300 Subject: 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 --- src/chunk.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/chunk.rs') diff --git a/src/chunk.rs b/src/chunk.rs index 469185f..266d1a7 100644 --- a/src/chunk.rs +++ b/src/chunk.rs @@ -1,4 +1,4 @@ -use crate::checksummer::sha256; +use crate::checksummer::Checksum; use crate::chunkid::ChunkId; use crate::chunkmeta::ChunkMeta; use serde::{Deserialize, Serialize}; @@ -78,7 +78,7 @@ impl GenerationChunk { let json: String = serde_json::to_string(self).map_err(GenerationChunkError::JsonGenerate)?; let bytes = json.as_bytes().to_vec(); - let sha = sha256(&bytes); + let sha = Checksum::sha256(&bytes); let meta = ChunkMeta::new_generation(&sha, ended); Ok(DataChunk::new(bytes, meta)) } -- cgit v1.2.1