[][src]Struct dropbox_content_hasher::DropboxContentHasher

pub struct DropboxContentHasher { /* fields omitted */ }

Computes a hash using the same algorithm that the Dropbox API uses for the the "content_hash" metadata field.

Implements the digest::Digest trait, whose result() function returns a raw binary representation of the hash. The "content_hash" field in the Dropbox API is a hexadecimal-encoded version of this value.

For examples see hash_file and hash_reader, for an using this object directly see the source of hash_reader.

Methods

impl DropboxContentHasher
[src]

pub fn new() -> Self
[src]

pub fn hash_file<T>(path: T) -> Result<GenericArray<u8, Self::OutputSize>> where
    T: AsRef<Path>, 
[src]

Return the content_hash for a given file, or an io::Error from either opening or reading the file.

extern crate digest;
use dropbox_content_hasher::DropboxContentHasher;
use std::path::PathBuf;

let path = PathBuf::from("src/lib.rs");

let hex_hash = format!("{:x}", DropboxContentHasher::hash_file(&path).unwrap());
println!("{}", hex_hash);

pub fn hash_reader<T>(reader: T) -> Result<GenericArray<u8, Self::OutputSize>> where
    T: Read
[src]

Return the content_hash for a given object implementing Read, or an io::Error resulting from trying to read its contents.

extern crate digest;
use dropbox_content_hasher::DropboxContentHasher;

let mut f = std::fs::File::open("src/lib.rs").unwrap();

let hex_hash = format!("{:x}", DropboxContentHasher::hash_reader(&mut f).unwrap());
println!("{}", hex_hash);

Trait Implementations

impl Default for DropboxContentHasher
[src]

impl Clone for DropboxContentHasher
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for DropboxContentHasher
[src]

impl Reset for DropboxContentHasher
[src]

impl FixedOutput for DropboxContentHasher
[src]

type OutputSize = <Sha256 as FixedOutput>::OutputSize

impl Input for DropboxContentHasher
[src]

fn chain<B>(self, data: B) -> Self where
    B: AsRef<[u8]>, 
[src]

Digest input data in a chained manner.

impl BlockInput for DropboxContentHasher
[src]

type BlockSize = U64

Auto Trait Implementations

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<D> Digest for D where
    D: Input + FixedOutput + Reset + Clone + Default
[src]

type OutputSize = <D as FixedOutput>::OutputSize

impl<D> DynDigest for D where
    D: Input + FixedOutput + Reset + Clone
[src]

fn input(&mut self, data: &[u8])
[src]

Digest input data.

This method can be called repeatedly for use with streaming messages.

fn result_reset(&mut self) -> Box<[u8]>
[src]

Retrieve result and reset hasher instance

fn result(self: Box<D>) -> Box<[u8]>
[src]

Retrieve result and consume boxed hasher instance

fn output_size(&self) -> usize
[src]

Get output size of the hasher

impl<T> Same for T

type Output = T

Should always be Self