{"id":13440098,"url":"https://github.com/ps1dr3x/easy_reader","last_synced_at":"2025-06-20T19:38:02.632Z","repository":{"id":32062926,"uuid":"131485471","full_name":"ps1dr3x/easy_reader","owner":"ps1dr3x","description":"A Rust library (crate) for reading and easily navigating forward, backward or randomly through the lines of huge files. Tested with files of over 300 GB.","archived":false,"fork":false,"pushed_at":"2022-02-16T17:42:34.000Z","size":103,"stargazers_count":88,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-19T00:08:32.879Z","etag":null,"topics":["backward","crate","files","forward","huge","huge-files","linereader","lines","random","read","reader","reverse","rust","rustlang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ps1dr3x.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-29T10:33:24.000Z","updated_at":"2025-03-31T21:11:38.000Z","dependencies_parsed_at":"2022-08-07T17:15:10.419Z","dependency_job_id":null,"html_url":"https://github.com/ps1dr3x/easy_reader","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/ps1dr3x/easy_reader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ps1dr3x%2Feasy_reader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ps1dr3x%2Feasy_reader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ps1dr3x%2Feasy_reader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ps1dr3x%2Feasy_reader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ps1dr3x","download_url":"https://codeload.github.com/ps1dr3x/easy_reader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ps1dr3x%2Feasy_reader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261005789,"owners_count":23095915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backward","crate","files","forward","huge","huge-files","linereader","lines","random","read","reader","reverse","rust","rustlang"],"created_at":"2024-07-31T03:01:19.765Z","updated_at":"2025-06-20T19:37:57.598Z","avatar_url":"https://github.com/ps1dr3x.png","language":"Rust","readme":"# EasyReader\n\n[![Build Status](https://travis-ci.org/ps1dr3x/easy_reader.svg?branch=master)](https://travis-ci.org/ps1dr3x/easy_reader)\n[![Latest Version](https://img.shields.io/crates/v/easy_reader.svg)](https://crates.io/crates/easy_reader)\n[![Documentation](https://docs.rs/easy_reader/badge.svg)](https://docs.rs/easy_reader)\n[![Rustc Version](https://img.shields.io/badge/rustc-1.52+-green.svg)](https://rust-lang.org/)\n\nThe main goal of this library is to allow long navigations through the lines of large files, freely moving forwards and backwards or getting random lines without having to consume an iterator.\n\nCurrently with Rust's standard library is possible to read a file line by line only through Lines (https://doc.rust-lang.org/std/io/trait.BufRead.html#method.lines), with which is impossible (or very expensive) to read backwards and to get random lines. Also, being an iterator, every line that has already been read is consumed and to get back to the same line you need to reinstantiate the reader and consume all the lines until the desired one (eg. in the case of the last line, all).\n\n**Notes:**\n\nEasyReader by default does not generate an index, it just searches for line terminators from time to time, this allows it to be used with very large files without \"startup\" times and excessive RAM consumption.\nHowever, the lack of an index makes the reading slower and does not allow to take random lines with a perfect distribution, for these reasons there's a method to generate it; the start time will be slower, but all the following readings will use it and will therefore be faster (excluding the index build time, reading times are a bit longer but still comparable to those of a sequential forward reading through Lines) and in the random reading case the lines will be taken with a perfect distribution.\nBy the way, it's not advisable to generate the index for very large files, as an excessive RAM consumption could occur.\n\n### Example: basic usage\n\n```rust\nuse easy_reader::EasyReader;\nuse std::{\n    fs::File,\n    io::{\n        self,\n        Error\n    }\n};\n\nfn navigate() -\u003e Result\u003c(), Error\u003e {\n    let file = File::open(\"resources/test-file-lf\")?;\n    let mut reader = EasyReader::new(file)?;\n\n    // Generate index (optional)\n    reader.build_index();\n\n    // Move through the lines\n    println!(\"First line: {}\", reader.next_line()?.unwrap());\n    println!(\"Second line: {}\", reader.next_line()?.unwrap());\n    println!(\"First line: {}\", reader.prev_line()?.unwrap());\n    println!(\"Random line: {}\", reader.random_line()?.unwrap());\n\n    // Iteration through the entire file (reverse)\n    reader.eof();\n    while let Some(line) = reader.prev_line()? {\n        println!(\"{}\", line);\n    }\n\n    // You can always start/restart reading from the end of file (EOF)\n    reader.eof();\n    println!(\"Last line: {}\", reader.prev_line()?.unwrap());\n    // Or the begin of file (BOF)\n    reader.bof();\n    println!(\"First line: {}\", reader.next_line()?.unwrap());\n\n    Ok(())\n}\n```\n\n### Example: read random lines endlessly\n\n```rust\nuse easy_reader::EasyReader;\nuse std::{\n    fs::File,\n    io::{\n        self,\n        Error\n    }\n};\n\nfn navigate_forever() -\u003e Result\u003c(), Error\u003e {\n    let file = File::open(\"resources/test-file-lf\")?;\n    let mut reader = EasyReader::new(file)?;\n\n    // Generate index (optional)\n    reader.build_index();\n\n    loop {\n        println!(\"{}\", reader.random_line()?.unwrap());\n    }\n}\n```\n","funding_links":[],"categories":["Libraries","Rust","库 Libraries","库"],"sub_categories":["Text processing","文本处理 Text processing","文本处理"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fps1dr3x%2Feasy_reader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fps1dr3x%2Feasy_reader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fps1dr3x%2Feasy_reader/lists"}