From: Ian Jackson Date: Mon, 3 May 2021 18:51:36 +0000 (+0100) Subject: utils: provide DigestWrite::sink X-Git-Tag: otter-0.6.0~423 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2136516ff576e746b98b676e5d3a1903848806c1;p=otter.git utils: provide DigestWrite::sink Signed-off-by: Ian Jackson --- diff --git a/src/bin/otter.rs b/src/bin/otter.rs index 13f708a1..a90d25f1 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::::new(io::sink()); + let mut dw = DigestWrite::::sink(); io::copy(&mut f, &mut dw).context("read bundle file (for hash)")?; dw.finish().0 }; diff --git a/src/utils.rs b/src/utils.rs index 204a3679..fd27c32a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -582,6 +582,9 @@ impl DigestWrite { (self.d.finalize(), self.w) } } +impl DigestWrite { + pub fn sink() -> Self { DigestWrite::new(io::sink()) } +} impl Write for DigestWrite { #[throws(io::Error)]