[go: up one dir, main page]

copy_hash_sync

Function copy_hash_sync 

Source
pub fn copy_hash_sync<P, Q>(cache: P, sri: &Integrity, to: Q) -> Result<u64>
where P: AsRef<Path>, Q: AsRef<Path>,
Expand description

Copies a cache entry by integrity address to a specified location. Returns the number of bytes copied.

On platforms that support it, this will create a copy-on-write “reflink” with a full-copy fallback.

§Example

use std::io::Read;

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