#read-file #file #io #last #seek #blocking #skip

blocking-reader

read a file async, will log last read seek and skip to last read when in a loop

1 unstable release

0.1.0 Jun 5, 2023

#22 in #skip

MIT/Apache

15KB
68 lines

read a file async, will log last read seek and skip to last read when in a loop

Basic Usage

use blocking_reader::file::FileReadExt;
use std::time::Duration;

#[tokio::main]
async fn main() {
    tracing_subscriber::fmt::init();
    let filepath = "/var/log/syslog";
    loop {
        let results = filepath
            .blocking_read_with_time_limit(&vec![], Duration::from_secs(30))
            .await
            .unwrap();
        if results.len() < 100 {
            println!("{results:?}");
        }

        tokio::time::sleep(Duration::from_secs(1)).await;
    }
}

Dependencies

~9–21MB
~309K SLoC