cacache

Function read_hash_sync

Source
pub fn read_hash_sync<P>(cache: P, sri: &Integrity) -> Result<Vec<u8>>
where P: AsRef<Path>,
Expand description

Reads the entire contents of a cache file synchronously into a bytes vector, looking the data up by its content address.

ยงExample

use std::io::Read;

fn main() -> cacache::Result<()> {
    let sri = cacache::write_sync("./my-cache", "my-key", b"hello")?;
    let data = cacache::read_hash_sync("./my-cache", &sri)?;
    Ok(())
}