use std::path::Path;
use std::fs;

fn truncate_file<P: AsRef<Path>>(filename: P, filesize: usize) -> Result<(), Error> {
    use Error::*;
    let file = fs::read(&filename).or(Err(NotFound))?;

    if filesize > file.len() {
        return Err(FilesizeTooSmall)
    }

    fs::write(&filename, &file[..filesize]).or(Err(UnableToWrite))?;
    Ok(())
}

#[derive(Debug)]
enum Error {