5 releases (3 breaking)

Uses old Rust 2015

0.4.0 Apr 29, 2018
0.3.0 Aug 3, 2017
0.2.0 May 20, 2017
0.1.1 Feb 1, 2017
0.1.0 Jan 31, 2016

#719 in Asynchronous

Download history 179/week @ 2023-12-06 519/week @ 2023-12-13 204/week @ 2023-12-20 116/week @ 2023-12-27 355/week @ 2024-01-03 285/week @ 2024-01-10 445/week @ 2024-01-17 239/week @ 2024-01-24 268/week @ 2024-01-31 349/week @ 2024-02-07 364/week @ 2024-02-14 429/week @ 2024-02-21 340/week @ 2024-02-28 467/week @ 2024-03-06 419/week @ 2024-03-13 541/week @ 2024-03-20

1,856 downloads per month
Used in 16 crates (13 directly)

Apache-2.0

27KB
353 lines

Filebuffer

Fast and simple file reading for Rust.

Build Status Build Status Crates.io version Documentation

Filebuffer can map files into memory. This is often faster than using the primitives in std::io, and also more convenient. Furthermore this crate offers prefetching and checking whether file data is resident in physical memory (so access will not incur a page fault). This enables non-blocking file reading.

Example

Below is an implementation of the sha256sum program that is both faster and simpler than the naive std::io equivalent. (See sha256sum_filebuffer and sha256sum_naive in the examples directory.)

use std::env;
use crypto::digest::Digest;
use crypto::sha2::Sha256;
use filebuffer::FileBuffer;

extern crate crypto;
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.input(&fbuffer);
        println!("{}  {}", hasher.result_str(), fname);
    }
}

License

Filebuffer is licensed under the Apache 2.0 license. It may be used in free software as well as closed-source applications, both for commercial and non-commercial use under the conditions given in the license. If you want to use Filebuffer in your GPLv2-licensed software, you can add an exception to your copyright notice.

Dependencies

~215KB