#chunking #file #concurrency #chunks

file-chunker

Efficiently process a file in (approximately) equally-sized parts

2 releases

0.1.1 Feb 10, 2022
0.1.0 Feb 9, 2022

#1777 in Filesystem

Download history 185/week @ 2025-08-31 99/week @ 2025-09-07 456/week @ 2025-09-14 170/week @ 2025-09-21 100/week @ 2025-09-28 92/week @ 2025-10-05 249/week @ 2025-10-12 79/week @ 2025-10-19 117/week @ 2025-10-26 342/week @ 2025-11-02 172/week @ 2025-11-09 73/week @ 2025-11-16 63/week @ 2025-11-23 95/week @ 2025-11-30 58/week @ 2025-12-07 29/week @ 2025-12-14

266 downloads per month
Used in krapslog

MIT license

17KB
222 lines

file-chunker

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.

Example

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);
    });

Dependencies

~230–305KB