[][src]Function read_restrict::read

pub fn read<P: AsRef<Path>>(path: P, restriction: usize) -> Result<Vec<u8>>

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

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

Examples

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