1
0
Fork
You've already forked filebuffer
0
Fast and simple file reading for Rust https://github.com/ruuda/filebuffer
  • Rust 100%
Find a file
2026年01月13日 21:17:25 +01:00
.github/workflows Switch CI from AppVeyor to GitHub Actions 2026年01月13日 21:07:40 +01:00
examples Replace rust-crypto crate with sha2 2026年01月10日 18:44:08 +01:00
src Replace usage of try! with ? operator 2024年05月18日 15:50:42 +02:00
.gitignore Put Cargo.lock under source control 2017年02月07日 13:45:55 +01:00
build.rcl Switch CI from AppVeyor to GitHub Actions 2026年01月13日 21:07:40 +01:00
Cargo.lock Bump version to 1.0.1 2026年01月13日 21:17:25 +01:00
Cargo.toml Bump version to 1.0.1 2026年01月13日 21:17:25 +01:00
changelog.md Bump version to 1.0.1 2026年01月13日 21:17:25 +01:00
contributing.md Ban the use of LLMs in the issue tracker 2025年12月03日 20:20:16 +01:00
license License project under the Apache License 2.0 2016年01月29日 09:23:52 +01:00
readme.md Remove badges from Cargo config and readme 2024年05月18日 15:50:42 +02:00
rust-toolchain.toml Switch CI from AppVeyor to GitHub Actions 2026年01月13日 21:07:40 +01:00

Filebuffer

Fast and simple file reading for Rust.

Crates.io version Changelog 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.)

usestd::env;usecrypto::digest::Digest;usecrypto::sha2::Sha256;usefilebuffer::FileBuffer;externcratecrypto;externcratefilebuffer;fn main(){forfnameinenv::args().skip(1){letfbuffer=FileBuffer::open(&fname).expect("failed to open file");letmuthasher=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.