From 2136516ff576e746b98b676e5d3a1903848806c1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 3 May 2021 19:51:36 +0100 Subject: [PATCH] utils: provide DigestWrite::sink Signed-off-by: Ian Jackson --- src/bin/otter.rs | 2 +- src/utils.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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)] -- 2.30.2