blocking-reader

Crates.ioblocking-reader
lib.rsblocking-reader
version0.1.0
sourcesrc
created_at2023-06-05 06:41:41.140964
updated_at2023-06-05 06:41:41.140964
descriptionread a file async, will log last read seek and skip to last read when in a loop
homepage
repository
max_upload_size
id882828
size46,578
gongzhengyang (gongzhengyang)

documentation

README

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;
    }
}
Commit count: 0

cargo fmt