Crates.io | tokio-rev-lines |
lib.rs | tokio-rev-lines |
version | 0.2.1 |
source | src |
created_at | 2022-07-11 07:31:43.488841 |
updated_at | 2022-07-12 06:30:35.989818 |
description | This library provides an async stream for reading files or any `BufReader` line by line with buffering in reverse. |
homepage | |
repository | https://github.com/JasonWei512/tokio-rev-lines |
max_upload_size | |
id | 623615 |
size | 17,593 |
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 is available on Docs.rs.
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(())
}