pub fn read_text_capped(path: &Path, max_bytes: u64) -> Result<String>Expand description
Reads a UTF-8 text file with a hard byte cap (memory / OOM hygiene).
Checks metadata().len() first, then reads with Take(max+1) so a TOCTOU
grow cannot allocate unbounded heap. Rejects files larger than max_bytes.
ยงErrors
Returns std::io::Error on I/O failure or when the file exceeds max_bytes.