[][src]Function read_restrict::read_to_string

pub fn read_to_string<P: AsRef<Path>>(
    path: P,
    restriction: usize
) -> Result<String>

Read the entire contents of a file into a string, provided it fits within a specified size limit.

This is a restricted alternative to std::fs::read_to_string with otherwise identical semantics.

Examples

fn main() -> std::io::Result<()> {
    let string_at_most_64_bytes = read_restrict::read_to_string("foo.txt", 64)?;
    Ok(())
}