| Crates.io | file-chunker |
| lib.rs | file-chunker |
| version | 0.1.1 |
| created_at | 2022-02-09 12:50:28.841306+00 |
| updated_at | 2022-02-10 12:49:31.868224+00 |
| description | Efficiently process a file in (approximately) equally-sized parts |
| homepage | https://github.com/acj/file-chunker |
| repository | https://github.com/acj/file-chunker |
| max_upload_size | |
| id | 529685 |
| size | 18,169 |
This crate provides the FileChunker type, which is useful for efficiently reading a file
in (approximately) equally-sized parts.
The original use case was to process a log file in chunks, one thread per chunk, and to guarantee that each chunk ended with a full line of text.
use file_chunker::FileChunker;
let file = std::fs::File::open("/path/to/file").unwrap();
let chunker = FileChunker::new(&file).unwrap();
chunker.chunks(1024, Some('\n'))
.unwrap()
.iter()
.for_each(|chunk| {
println!("{:?}", chunk);
});