pub(crate) fn cache_object_computation<
    T: Serialize + DeserializeOwned,
    F: FnOnce() -> Fallible<T>,
>(
    cache_path: &Path,
    object_name: &str,
    hash: HashCode,
    key: &str,
    f: F,
) -> Fallible<T> {
    //Just like the file scenario, use the object's hash to detect changes
    let results_path = cached_results_path(Path::new(object_name), key, hash);

    //Try to load a cached results file.  If it doesn't exist or there's any kind of error loading
    //it, just invoke the function again
    let abs_path = cache_generated_file(cache_path, &results_path, |abs_path| {
        f().and_then(|result| {
            //Result was computed; serialize it back
            save_results::<T>(&abs_path, &result).and(Ok(abs_path))
        })
    })?;

    load_cached_results::<T>(&abs_path)
}
/// Similar to `cache_file_computation`, except the computation is not on the contents of a file
/// but rather on some arbitrary object with a name and a hash.  If the computation has previously
/// been performed on the same name and hash, the previous result is returned.  Otherwise the
/// computation is performed and saved in the cache for future invocations.
Similar to `cache_file_computation`, except the computation is not on the contents of a file
but rather on some arbitrary object with a name and a hash.  If the computation has previously
been performed on the same name and hash, the previous result is returned.  Otherwise the
computation is performed and saved in the cache for future invocations.
Similar to ` cache_file_computation ` except the computation is not on the contents of a file but rather on some arbitrary object with a name and a hash . If the computation has previously been performed on the same name and hash the previous result is returned . Otherwise the computation is performed and saved in the cache for future invocations .
pub(crate) fn cache_object_computation<
    T: Serialize + DeserializeOwned,
    F: FnOnce() -> Fallible<T>,
>(
    cache_path: &Path,
    object_name: &str,
    hash: HashCode,
    key: &str,
    f: F,
) -> Fallible<T> {
    //Just like the file scenario, use the object's hash to detect changes
    let results_path = cached_results_path(Path::new(object_name), key, hash);
    //Try to load a cached results file.  If it doesn't exist or there's any kind of error loading
    //it, just invoke the function again
    let abs_path = cache_generated_file(cache_path, &results_path, |abs_path| {
        f().and_then(|result| {
            //Result was computed; serialize it back
            save_results::<T>(&abs_path, &result).and(Ok(abs_path))
        })
    })?;
    load_cached_results::<T>(&abs_path)
}
pub ( crate ) fn cache_object_computation < T : Serialize + DeserializeOwned , F : FnOnce ( ) -> Fallible < T > , > ( cache_path : & Path , object_name : & str , hash : HashCode , key : & str , f : F , ) -> Fallible < T > { //Just like the file scenario, use the object's hash to detect changes let results_path = cached_results_path ( Path :: new ( object_name ) , key , hash ) ; //Try to load a cached results file.  If it doesn't exist or there's any kind of error loading //it, just invoke the function again let abs_path = cache_generated_file ( cache_path , & results_path , | abs_path | { f ( ) . and_then ( | result | { //Result was computed; serialize it back save_results :: < T > ( & abs_path , & result ) . and ( Ok ( abs_path ) ) } ) } ) ? ; load_cached_results :: < T > ( & abs_path ) }
Similar to `cache_file_computation`, except the computation is not on the contents of a file
but rather on some arbitrary object with a name and a hash.
Similar to ` cache_file_computation ` except the computation is not on the contents of a file but rather on some arbitrary object with a name and a hash .
cache_path
&Path
object_name
&str
hash
HashCode
key
&str
f
F
cache_path
&Path
object_name
&str
hash
HashCode
key
&str
f
F