4 releases
0.2.1 | Jul 12, 2022 |
---|---|
0.2.0 | Jul 12, 2022 |
0.1.1 | Jul 11, 2022 |
0.1.0 | Jul 11, 2022 |
#13 in #lines
12KB
174 lines
tokio-rev-lines
This library provides an async stream for reading files or any BufReader
line by line with buffering in reverse.
It's an async tokio version of rev_lines.
Documentation
Documentation is available on Docs.rs.
Example
use futures_util::{pin_mut, StreamExt};
use tokio::{fs::File, io::BufReader};
use tokio_rev_lines::RevLines;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let file = File::open("tests/multi_line_file").await?;
let rev_lines = RevLines::new(BufReader::new(file)).await?;
pin_mut!(rev_lines);
while let Some(line) = rev_lines.next().await {
println!("{}", line?);
}
Ok(())
}
lib.rs
:
This library provides an async stream for reading files or any BufReader
line by line with buffering in reverse.
It's an async tokio version of rev_lines.
Example
use futures_util::{pin_mut, StreamExt};
use tokio::{fs::File, io::BufReader};
use tokio_rev_lines::RevLines;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let file = File::open("tests/multi_line_file").await?;
let rev_lines = RevLines::new(BufReader::new(file)).await?;
pin_mut!(rev_lines);
while let Some(line) = rev_lines.next().await {
println!("{}", line?);
}
Ok(())
}
This method uses logic borrowed from uutils/coreutils tail
Dependencies
~2.9–9MB
~79K SLoC