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]

[src]

Wrap a Digest into a Writer

[src]

Returns a reference to underlying Digest object

[src]

Returns a mutable reference to underlying Digest object

[src]

Return the original Digest

Trait Implementations

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

[src]

Formats the value using the given formatter.

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

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

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

[src]

Returns the "default value" for a type. Read more

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

[src]

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

[src]

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

1.0.0
[src]

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

1.0.0
[src]

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

1.0.0
[src]

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

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

[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]

[src]

Retrieve the digest result. This method consumes digest instance.

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

[src]

Create new hasher instance with given output size. Will return Err(InvalidLength) in case if hasher can not work with the given output size. Will always return an error if output size equals to zero. Read more

[src]

Get output size of the hasher instance provided to the new method

[src]

Retrieve the digest result into provided buffer. Length of the buffer must be equal to output size provided to the new method, otherwise Err(InvalidLength) will be returned Read more