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

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

#23 in #last

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–24MB
~308K SLoC