From b9f95b4ce4887c481ac4934e02a7a3aca4a316a6 Mon Sep 17 00:00:00 2001 From: Cody P Schafer Date: Fri, 7 Nov 2014 12:19:01 -0500 Subject: [PATCH] crypto/hash: impl Writer for Hasher to allow use of Reader-Writer convenience functions --- src/crypto/hash.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/crypto/hash.rs b/src/crypto/hash.rs index a72b8d9f..60517adf 100644 --- a/src/crypto/hash.rs +++ b/src/crypto/hash.rs @@ -1,5 +1,6 @@ use libc::c_uint; use std::ptr; +use std::io; use ffi; @@ -34,6 +35,13 @@ pub struct Hasher { len: uint, } +impl io::Writer for Hasher { + fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { + self.update(buf); + Ok(()) + } +} + impl Hasher { pub fn new(ht: HashType) -> Hasher { ffi::init();