bring back Block read/write for now
@@ -14,6 +14,7 @@ use std::arch::x86_64::*;
#[cfg(feature = "serde")]
use std::convert::TryInto;
use std::hash::{Hash, Hasher};
+use std::io::{Read, Write};
/// A 128-bit chunk.
#[derive(Clone, Copy)]
@@ -89,6 +90,18 @@ impl Block {
c.encrypt(Block::from(m))
}
+ /// Write a block to `stream`.
+ #[inline]
+ pub fn write<T: Write>(&self, stream: &mut T) -> Result<usize, std::io::Error> {
+ stream.write(self.as_ref())
+ }
+ /// Read a block from `stream`.
+ #[inline]
+ pub fn read<T: Read>(stream: &mut T) -> Result<Block, std::io::Error> {
+ let mut v = Block::default();
+ stream.read_exact(v.as_mut())?;
+ Ok(v)
+ }
/// Return the "color" bit (when viewing `Block` as a wire label).
#[inline]
pub fn color_bit(&self) -> bool {
