MCPcopy Index your code
hub / github.com/faern/rustscript / hash_script

Function hash_script

src/hash.rs:10–15  ·  view source on GitHub ↗
(script_path: P)

Source from the content-addressed store, hash-verified

8use std::path::Path;
9
10pub fn hash_script<P: AsRef<Path>>(script_path: P) -> Result<(String, String)> {
11 let mut f = File::open(&script_path).chain_err(|| "Unable to open script file")?;
12 let mut buffer = Vec::new();
13 f.read_to_end(&mut buffer).chain_err(|| "Unable to read script")?;
14 Ok((hash_path(script_path)?, hash(&buffer)))
15}
16
17fn hash_path<P: AsRef<Path>>(p: P) -> Result<String> {
18 // let current_dir = ::std::env::current_dir().error_chain(|| "Unable to get current directory")?;

Callers 1

runFunction · 0.85

Calls 2

hash_pathFunction · 0.85
hashFunction · 0.85

Tested by

no test coverage detected