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
This commit is contained in:
Henry de Valence 2019-09-25 14:05:30 -07:00 committed by Deirdre Connolly
parent 44b855aab8
commit 64b210b53c
1 changed files with 8 additions and 0 deletions

View File

@ -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.