Struct digest_writer::Writer
[−]
[src]
pub struct Writer<D>(_);
A wrapper around Digest type that allows to use Write trait for hashing
Example
extern crate sha2; extern crate digest; extern crate digest_writer; use std::fs::File; use std::io::{self, Write}; use digest::Digest; use digest_writer::Writer; let mut digest = Writer::new(sha2::Sha256::new()); let mut f = File::open("LICENSE-MIT").unwrap(); io::copy(&mut f, &mut digest).unwrap(); digest.result();
Methods
impl<D: Digest> Writer<D>
[src]
fn new(d: D) -> Writer<D>
Wrap a Digest into a Writer
fn get_ref(&self) -> &D
Returns a reference to underlying Digest object
fn get_mut(&mut self) -> &D
Returns a mutable reference to underlying Digest object
fn into_inner(self) -> D
Return the original Digest
Trait Implementations
impl<D: Debug> Debug for Writer<D>
[src]
impl<D: Clone> Clone for Writer<D>
[src]
fn clone(&self) -> Writer<D>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<D: Digest> Write for Writer<D>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Write
. Read more
impl<D: Digest> Digest for Writer<D>
[src]
type OutputSize = D::OutputSize
type BlockSize = D::BlockSize
fn input(&mut self, input: &[u8])
Digest input data. This method can be called repeatedly for use with streaming messages. Read more
fn result(self) -> GenericArray<u8, Self::OutputSize>
Retrieve the digest result. This method consumes digest instance.
fn block_bytes(&self) -> usize
Get the block size in bytes.
fn block_bits(&self) -> usize
Get the block size in bits.
fn output_bytes(&self) -> usize
Get the output size in bytes.
fn output_bits(&self) -> usize
Get the output size in bits.