Skip to content

Create a stream from a std::io::Read using Tokio blocking threads

License

Notifications You must be signed in to change notification settings

wilsonzlin/tokio-sync-read-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();
}

About

Create a stream from a std::io::Read using Tokio blocking threads

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages