Skip to main content

read_bounded_text

Function read_bounded_text 

pub fn read_bounded_text(path: &Path, what: &str) -> Result<String>
Expand description

Reads the base RunConfig file without letting its size decide the child’s.

The read itself is bounded, not just the verdict: an oversized file must never be allocated before it is refused, which is why the reader is capped at one byte past MAX_CONFIG_BYTES rather than checked after a full read_to_string. One extra byte is what distinguishes “exactly at the limit” from “longer than the limit”.

§Errors

Returns SpikeError::Io when the file cannot be opened or read, or SpikeError::ResourceCap when more than MAX_CONFIG_BYTES bytes are present.