All Projects → ps1dr3x → easy_reader

ps1dr3x / easy_reader

Licence: Apache-2.0 license
⏮ ⏯ ⏭ A Rust library for easily navigating forward, backward or randomly through the lines of huge files.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to easy reader

readability-cli
A CLI for Mozilla Readability. Get clean, uncluttered, ready-to-read HTML from any webpage!
Stars: ✭ 41 (-50.6%)
Mutual labels:  read, reader
mps
MPS is a high-performance HTTP(S) proxy library that supports forward proxies, reverse proxies, man-in-the-middle proxies, tunnel proxies, Websocket proxies. MPS 是一个高性能HTTP(s)中间代理库,它支持正向代理、反向代理、中间人代理、隧道代理、Websocket代理
Stars: ✭ 64 (-22.89%)
Mutual labels:  reverse, forward
files-io
Read many files with node
Stars: ✭ 19 (-77.11%)
Mutual labels:  files, read
qrrs
CLI QR code generator and reader written in rust
Stars: ✭ 29 (-65.06%)
Mutual labels:  reader, rustlang
PoReader
本地小说阅读器,支持深色模式,Wifi传书,代码简洁有注释(local text reader, support dark modal, upload text by wifi)
Stars: ✭ 41 (-50.6%)
Mutual labels:  read, reader
SharpLoader
🔮 [C#] Source code randomizer and compiler
Stars: ✭ 36 (-56.63%)
Mutual labels:  random, lines
Kirby3 Autoid
Automatic unique ID for Pages, Files and Structures including performant helpers to retrieve them. Bonus: Tiny-URL.
Stars: ✭ 58 (-30.12%)
Mutual labels:  files, random
Lsix
Like "ls", but for images. Shows thumbnails in terminal using sixel graphics.
Stars: ✭ 2,635 (+3074.7%)
Mutual labels:  files
aes-stream
A fast AES-PRF based secure random-number generator
Stars: ✭ 15 (-81.93%)
Mutual labels:  random
Ultracopier
Ultracopier acts as a replacement for files copy dialogs. Features: play/pause, speed limitation, on-error resume, error/collision management ...
Stars: ✭ 220 (+165.06%)
Mutual labels:  files
Nova Filemanager
A Filemanager tool for Laravel Nova
Stars: ✭ 189 (+127.71%)
Mutual labels:  files
Copy Webpack Plugin
Copy files and directories with webpack
Stars: ✭ 2,679 (+3127.71%)
Mutual labels:  files
cheryl
PHP web based file manager
Stars: ✭ 44 (-46.99%)
Mutual labels:  files
Telegram Upload
Upload and download files from Telegram up to 2GiB using your account
Stars: ✭ 223 (+168.67%)
Mutual labels:  files
SmsForwarder
短信转发器——监控Android手机短信、来电、APP通知,并根据指定规则转发到其他手机:钉钉群自定义机器人、钉钉企业内机器人、企业微信群机器人、飞书机器人、企业微信应用消息、邮箱、bark、webhook、Telegram机器人、Server酱、PushPlus、手机短信等。包括主动控制服务端与客户端,让你轻松远程发短信、查短信、查通话、查话簿、查电量等。(V3.0 新增)PS.这个APK主要是学习与自用,如有BUG请提ISSUE,同时欢迎大家提PR指正
Stars: ✭ 8,386 (+10003.61%)
Mutual labels:  forward
Droppable
A javascript library to give file dropping super-powers to any HTML element.
Stars: ✭ 204 (+145.78%)
Mutual labels:  files
grand
Grand is a Go random string generator
Stars: ✭ 12 (-85.54%)
Mutual labels:  random
kafka-connect-fs
Kafka Connect FileSystem Connector
Stars: ✭ 107 (+28.92%)
Mutual labels:  files
movies-dataset
A dataset of films, directors, actresses and actors
Stars: ✭ 17 (-79.52%)
Mutual labels:  random
rust-for-backend-development
SWITCH TO RUST AND STOP WASTING YOUR TIME WITH JAVASCRIPT RUNTIME EXCEPTIONS
Stars: ✭ 30 (-63.86%)
Mutual labels:  rustlang

EasyReader

Build Status Latest Version Documentation Rustc Version

The 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.

Currently 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).

Notes:

EasyReader 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. However, 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. By the way, it's not advisable to generate the index for very large files, as an excessive RAM consumption could occur.

Example: basic usage

use easy_reader::EasyReader;
use std::{
    fs::File,
    io::{
        self,
        Error
    }
};

fn navigate() -> Result<(), Error> {
    let file = File::open("resources/test-file-lf")?;
    let mut reader = EasyReader::new(file)?;

    // Generate index (optional)
    reader.build_index();

    // Move through the lines
    println!("First line: {}", reader.next_line()?.unwrap());
    println!("Second line: {}", reader.next_line()?.unwrap());
    println!("First line: {}", reader.prev_line()?.unwrap());
    println!("Random line: {}", reader.random_line()?.unwrap());

    // Iteration through the entire file (reverse)
    reader.eof();
    while let Some(line) = reader.prev_line()? {
        println!("{}", line);
    }

    // You can always start/restart reading from the end of file (EOF)
    reader.eof();
    println!("Last line: {}", reader.prev_line()?.unwrap());
    // Or the begin of file (BOF)
    reader.bof();
    println!("First line: {}", reader.next_line()?.unwrap());

    Ok(())
}

Example: read random lines endlessly

use easy_reader::EasyReader;
use std::{
    fs::File,
    io::{
        self,
        Error
    }
};

fn navigate_forever() -> Result<(), Error> {
    let file = File::open("resources/test-file-lf")?;
    let mut reader = EasyReader::new(file)?;

    // Generate index (optional)
    reader.build_index();

    loop {
        println!("{}", reader.random_line()?.unwrap());
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].