tokio-sync-read-stream

Crates.iotokio-sync-read-stream
lib.rstokio-sync-read-stream
version0.1.0
sourcesrc
created_at2023-03-28 10:51:56.302948
updated_at2023-03-28 10:51:56.302948
descriptionCreate a stream from a std::io::Read using Tokio blocking threads
homepagehttps://github.com/wilsonzlin/tokio-sync-read-stream
repositoryhttps://github.com/wilsonzlin/tokio-sync-read-stream.git
max_upload_size
id822915
size16,903
Wilson Lin (wilsonzlin)

documentation

README

tokio-sync-read-stream

Transforms a std::io::Read into a fallable futures::stream::Stream that yields Result<Vec<u8>, std::io::Error>.

Under the hood, it reads from the file in chunks of up to buffer_size on a Tokio blocking thread using spawn_blocking. A Handle to the Tokio runtime must be provided.

Usage

Add the library as a dependency:

cargo add tokio-sync-read-stream

Sample Rust code:

use std::io::File;
use tokio_sync_read_stream::SyncReadStream;

#[tokio::main]
async fn main() {
  let file = File::open("data.bin").unwrap();
  let stream: SyncReadStream<File> = file.into();
}
Commit count: 2

cargo fmt