lineriver

Crates.iolineriver
lib.rslineriver
version0.7.1
sourcesrc
created_at2023-07-22 21:11:43.44581
updated_at2024-02-17 19:47:01.639088
descriptionNon-blocking buffered line reader for Read objects
homepagehttps://github.com/lpenz/lineriver
repositoryhttps://github.com/lpenz/lineriver
max_upload_size
id923418
size40,960
Leandro Lisboa Penz (lpenz)

documentation

README

CI coveralls crates.io doc.rs

lineriver

lineriver is a rust crate that provides a non-blocking buffered line reader for Read objects.

The LineReader object is akin to a BufReader object that returns only complete lines, but without blocking. The LineRead trait, on the other hand, is akin to the BufRead trait - it concentrates the public API and allows us to create agnostic collections of LineReaders with distinct underlying types.

This crate works very well with the polling crate, which allows us to block waiting on data to be available in any one of multiple streams (files, sockets, etc.). It's an alternative to using threads and/or tokio.

See LineReader for details.

Usage

The simplest way to explain how to use LineReader is with a busy-loop example:

use lineriver::{LineReader, LineRead};

let mut linereader = LineReader::new(reader)?;
while !linereader.eof() {
    linereader.read_available()?;
    let lines = linereader.lines_get();
    for line in lines {
        print!("{}", line);
    }
}
Commit count: 26

cargo fmt