filebuffer 1.0.1

Fast and simple file reading
Documentation
// Filebuffer -- Fast and simple file reading
// Copyright 2016 Ruud van Asseldonk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// A copy of the License has been included in the root of the repository.

// This example implements the `sha256sum` program in Rust using the Filebuffer library. Compare
// with `sha256sum_naive` which uses the IO primitives in the standard library.

use std::env;
use filebuffer::FileBuffer;
use sha2::{Sha256, Digest};

extern crate filebuffer;

fn main() {
    for fname in env::args().skip(1) {
        let fbuffer = FileBuffer::open(&fname).expect("failed to open file");
        let mut hasher = Sha256::new();
        hasher.update(&fbuffer);
        let result = hasher.finalize();
        let result = hex::encode(result.as_slice());

        // Match the output format of `sha256sum`, which has two spaces between the hash and name.
        println!("{}  {}", result, fname);
    }
}