Skip to main content

read_cached_text

Function read_cached_text 

Source
pub fn read_cached_text(
    directory: &Path,
    identity: &BinaryIdentity,
    kind: &str,
) -> Option<Vec<u8>>
Expand description

What: The text of kind recorded for exactly this identity, or None for a missing, foreign, unreadable or stale entry. Why: Every fact that is a property of the executable’s bytes (its version, its compiled-in configuration path) shares the identity check and the private-file check; only the file name and tag differ.

In TS you’d write (pseudocode):

const file = await readFile(cacheFile(dir, identity, kind)); return file.startsWith(tag(kind) + identity.text + '\n') ? file.slice(...) : undefined;