pub fn read_file_capped(
path: &Path,
max_bytes: usize,
) -> Result<(Vec<u8>, bool)>Expand description
Read at most max_bytes from path. Returns (bytes, truncated) where
bytes.len() <= max_bytes and truncated is true when the file was
longer than the cap.
Unlike std::fs::read, a multi-gigabyte file never pulls more than
max_bytes (+1 probe byte) into memory.