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
.
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);
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);
Returns the "default value" for a type. Read more
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Reset hasher instance to its initial state and return current state.
Retrieve result and consume hasher instance.
Digest input data in a chained manner.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Create new hasher instance
Digest input data in a chained manner.
Retrieve result and consume hasher instance.
Retrieve result and reset hasher instance. Read more
Reset hasher instance to its initial state.
Get output size of the hasher
Convenience function to compute hash of the data
. It will handle hasher creation, data feeding and finalization. Read more
Digest input data.
This method can be called repeatedly for use with streaming messages.
Retrieve result and reset hasher instance
Retrieve result and consume boxed hasher instance
Reset hasher instance to its initial state.
Get output size of the hasher