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]

Wrap a Digest into a Writer

Returns a reference to underlying Digest object

Returns a mutable reference to underlying Digest object

Return the original Digest

Trait Implementations

impl<D: Debug> Debug for Writer<D>
[src]

Formats the value using the given formatter.

impl<D: Clone> Clone for Writer<D>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<D: Input> Write for Writer<D>
[src]

Write a buffer into this object, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Attempts to write an entire buffer into this write. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a "by reference" adaptor for this instance of Write. Read more

impl<D: Input> Input for Writer<D>
[src]

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]

impl<D> FixedOutput for Writer<D> where
    D: FixedOutput,
    D::OutputSize: ArrayLength<u8>, 
[src]

Retrieve the digest result. This method consumes digest instance.

impl<D: VariableOutput> VariableOutput for Writer<D>
[src]

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