From 64b210b53c3bfecea2f3c88d460cd3c1afc93e62 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Wed, 25 Sep 2019 14:05:30 -0700 Subject: [PATCH] Add a read_32_bytes helper method. These are starting to stack up but I think until generic arrays arrive the cure is worse than the disease :S --- zebra-chain/src/serialization.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zebra-chain/src/serialization.rs b/zebra-chain/src/serialization.rs index 9232d60d..971b7d1d 100644 --- a/zebra-chain/src/serialization.rs +++ b/zebra-chain/src/serialization.rs @@ -236,6 +236,14 @@ pub trait ReadZcashExt: io::Read { self.read_exact(&mut bytes)?; Ok(bytes) } + + /// Convenience method to read a `[u8; 32]`. + #[inline] + fn read_32_bytes(&mut self) -> io::Result<[u8; 32]> { + let mut bytes = [0; 32]; + self.read_exact(&mut bytes)?; + Ok(bytes) + } } /// Mark all types implementing `Read` as implementing the extension.