3 releases

0.1.2 Jul 31, 2021
0.1.1 Jul 25, 2021
0.1.0 Jul 11, 2021

#1954 in Rust patterns

Download history 13/week @ 2023-11-01 11/week @ 2023-11-08 9/week @ 2023-11-15 16/week @ 2023-11-22 16/week @ 2023-11-29 6/week @ 2023-12-06 11/week @ 2023-12-13 11/week @ 2023-12-20 7/week @ 2023-12-27 6/week @ 2024-01-03 9/week @ 2024-01-10 13/week @ 2024-01-17 8/week @ 2024-01-24 11/week @ 2024-01-31 10/week @ 2024-02-07 30/week @ 2024-02-14

60 downloads per month
Used in split-csv

AGPL-3.0

51KB
604 lines

IndexedFile

A library to read lines of a file directly without having to read more than the requested line.

Example

Non indexed files

use indexed_file::{Indexable, ReadByLine};

#[async_std::main]
async fn main() {
    // Open and index a file
    let mut file = indexed_file::File::open_raw("<some unindexed file>")
        .await
        .unwrap();

    // Get line count efficiently without reading the entire file
    let line_count = file.total_lines();

    // Read line 30 directly
    let line_30 = file.read_line(30).await.unwrap();
}

Indexed files

use indexed_file::{Indexable, ReadByLine};

#[async_std::main]
async fn main() {
    // Open an indexed file
    let mut file = indexed_file::File::open("<some indexed file>")
        .await
        .unwrap();

    // Read line 30 directly
    let line_30 = file.read_line(30).await.unwrap();
}

For more examples visit the examples directory.

No runtime deps