diff options
| author | Steven Fackler <[email protected]> | 2015-02-24 23:01:57 -0800 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2015-02-24 23:01:57 -0800 |
| commit | 6991cc6a30c7f2e480145c4d0c5692924d293043 (patch) | |
| tree | 7077d07e5027dacb26ff86f0b1ed93af2c59f4c4 /openssl/src/crypto/hash.rs | |
| parent | Switch to cargo liblibc (diff) | |
| download | rust-openssl-6991cc6a30c7f2e480145c4d0c5692924d293043.tar.xz rust-openssl-6991cc6a30c7f2e480145c4d0c5692924d293043.zip | |
Convert to new IO.
Diffstat (limited to 'openssl/src/crypto/hash.rs')
| -rw-r--r-- | openssl/src/crypto/hash.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/openssl/src/crypto/hash.rs b/openssl/src/crypto/hash.rs index f81532c9..29e180e5 100644 --- a/openssl/src/crypto/hash.rs +++ b/openssl/src/crypto/hash.rs @@ -1,6 +1,7 @@ use libc::c_uint; use std::iter::repeat; -use std::old_io::{IoError, Writer}; +use std::io::prelude::*; +use std::io; use ffi; @@ -73,10 +74,10 @@ use self::State::*; /// assert_eq!(res, spec); /// ``` /// -/// Use the `Writer` trait to supply the input in chunks. +/// Use the `Write` trait to supply the input in chunks. /// /// ``` -/// use std::old_io::Writer; +/// use std::io::prelude::*; /// use openssl::crypto::hash::{Hasher, Type}; /// let data = [b"\x42\xF4", b"\x97\xE0"]; /// let spec = b"\x7c\x43\x0f\x17\x8a\xef\xdf\x14\x87\xfe\xe7\x14\x4e\x96\x41\xe2"; @@ -168,10 +169,14 @@ impl Hasher { } } -impl Writer for Hasher { +impl Write for Hasher { #[inline] - fn write_all(&mut self, buf: &[u8]) -> Result<(), IoError> { + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.update(buf); + Ok(buf.len()) + } + + fn flush(&mut self) -> io::Result<()> { Ok(()) } } @@ -213,7 +218,7 @@ pub fn hash(t: Type, data: &[u8]) -> Vec<u8> { mod tests { use serialize::hex::{FromHex, ToHex}; use super::{hash, Hasher, Type}; - use std::old_io::Writer; + use std::io::prelude::*; fn hash_test(hashtype: Type, hashtest: &(&str, &str)) { let res = hash(hashtype, &*hashtest.0.from_hex().unwrap()); |