From 3173084f28033fedbeab5a2683c018b80325e864 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 3 May 2021 19:54:17 +0100 Subject: [PATCH] provide bundles::DigestWrite Signed-off-by: Ian Jackson --- src/bin/otter.rs | 2 +- src/bundles.rs | 3 ++- src/utils.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bin/otter.rs b/src/bin/otter.rs index a90d25f1..b8553adf 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -1342,7 +1342,7 @@ mod upload_bundle { .context("open bundle file")?; let mut f = BufReader::new(f); let hash = { - let mut dw = DigestWrite::::sink(); + let mut dw = bundles::DigestWrite::sink(); io::copy(&mut f, &mut dw).context("read bundle file (for hash)")?; dw.finish().0 }; diff --git a/src/bundles.rs b/src/bundles.rs index 1af062f4..05a23256 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -7,6 +7,7 @@ use crate::prelude::*; pub use crate::prelude::Sha512Trunc256 as Digester; +pub type DigestWrite = crate::utils::DigestWrite; #[derive(Debug,Copy,Clone,Hash,Eq,PartialEq,Serialize,Deserialize)] pub struct Hash(pub [u8; 32]); @@ -142,7 +143,7 @@ impl From<&'static str> for IncorporateError { pub struct Uploading { instance: Arc, id: Id, - file: DigestWrite>, + file: DigestWrite>, } #[throws(IE)] diff --git a/src/utils.rs b/src/utils.rs index fd27c32a..438984ff 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -603,7 +603,7 @@ fn test_digest_write() { let exp = Sha512Trunc256::digest(&ibuffer[..]); let mut obuffer = [0;4]; let inner = &mut obuffer[..]; - let mut dw = DigestWrite::::new(inner); + let mut dw = bundles::DigestWrite::new(inner); assert_eq!( dw.write(&ibuffer[..]).unwrap(), 3); let (got, recov) = dw.finish(); assert_eq!( recov, b"\0" ); -- 2.30.2