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::FixedOutput; use digest_writer::Writer; let mut digest = Writer::new(sha2::Sha256::default()); let mut f = File::open("LICENSE-MIT").unwrap(); io::copy(&mut f, &mut digest).unwrap(); digest.fixed_result();
Methods
impl<D: Input + FixedOutput> 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) -> &mut 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: Input> 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: Input> Input for Writer<D>
[src]
fn process(&mut self, input: &[u8])
Digest input data. This method can be called repeatedly for use with streaming messages. Read more
impl<D> BlockInput for Writer<D> where
D: BlockInput,
D::BlockSize: ArrayLength<u8>,
[src]
D: BlockInput,
D::BlockSize: ArrayLength<u8>,
impl<D> FixedOutput for Writer<D> where
D: FixedOutput,
D::OutputSize: ArrayLength<u8>,
[src]
D: FixedOutput,
D::OutputSize: ArrayLength<u8>,
type OutputSize = D::OutputSize
fn fixed_result(self) -> GenericArray<u8, Self::OutputSize>
Retrieve the digest result. This method consumes digest instance.
impl<D: VariableOutput> VariableOutput for Writer<D>
[src]
fn variable_result(self, buffer: &mut [u8]) -> Result<&[u8], InvalidLength>
Retrieve the digest result into provided buffer. Length of the output equals to the input buffer size. In case of invalid length Err(InvalidLength)
will be returned. This method consumes digest instance. Read more