Crates.io | blocking-reader |
lib.rs | blocking-reader |
version | 0.1.0 |
source | src |
created_at | 2023-06-05 06:41:41.140964 |
updated_at | 2023-06-05 06:41:41.140964 |
description | read a file async, will log last read seek and skip to last read when in a loop |
homepage | |
repository | |
max_upload_size | |
id | 882828 |
size | 46,578 |
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;
}
}