pub fn read_file<P: AsRef<Path>>(path: P, max_size: usize) -> Result<(Vec<u8>, bool), io::Error>
{
    let mut f = File::open(path)?;
    let mut buffer = vec![0; max_size + 1];
    let size_read = f.read(&mut buffer)?;
    let all_file = size_read < (max_size + 1);
    let resize_to = if all_file { size_read } else { max_size };
    buffer.resize_with(resize_to, Default::default);
    Ok((buffer, all_file))
}
// returns bytes read and if the whole file was read
returns bytes read and if the whole file was read
returns bytes read and if the whole file was read
pub fn read_file<P: AsRef<Path>>(path: P, max_size: usize) -> Result<(Vec<u8>, bool), io::Error>
{
    let mut f = File::open(path)?;
    let mut buffer = vec![0; max_size + 1];
    let size_read = f.read(&mut buffer)?;
    let all_file = size_read < (max_size + 1);
    let resize_to = if all_file { size_read } else { max_size };
    buffer.resize_with(resize_to, Default::default);
    Ok((buffer, all_file))
}
pub fn read_file < P : AsRef < Path > > ( path : P , max_size : usize ) -> Result < ( Vec < u8 > , bool ) , io :: Error > { let mut f = File :: open ( path ) ? ; let mut buffer = vec ! [ 0 max_size 1 ] ; let size_read = f . read ( & mut buffer ) ? ; let all_file = size_read < ( max_size + 1 ) ; let resize_to = if all_file { size_read } else { max_size } ; buffer . resize_with ( resize_to , Default :: default ) ; Ok ( ( buffer , all_file ) ) }
returns bytes read and if the whole file was read
returns bytes read and if the whole file was read
path
P
max_size
usize
path
P
max_size
usize