crypto/hash: impl Writer for Hasher to allow use of Reader-Writer convenience functions

This commit is contained in:
Cody P Schafer 2014-11-07 12:19:01 -05:00
parent 1b7ab0238e
commit b9f95b4ce4
1 changed files with 8 additions and 0 deletions

View File

@ -1,5 +1,6 @@
use libc::c_uint; use libc::c_uint;
use std::ptr; use std::ptr;
use std::io;
use ffi; use ffi;
@ -34,6 +35,13 @@ pub struct Hasher {
len: uint, len: uint,
} }
impl io::Writer for Hasher {
fn write(&mut self, buf: &[u8]) -> io::IoResult<()> {
self.update(buf);
Ok(())
}
}
impl Hasher { impl Hasher {
pub fn new(ht: HashType) -> Hasher { pub fn new(ht: HashType) -> Hasher {
ffi::init(); ffi::init();