io-pipe 0.1.1

This library add a thread safe way to create multi writers and single reader pipeline.
Documentation

IO Pipe library

Crates.io Version GitHub Actions Workflow Status docs.rs Crates.io License

This library add a thread safe way to create multi writers and single reader pipeline. Best way to use that library is writing bytes in few threads and reading that bytes in another single thread.

How to

docs.rs documentation is here

Install

cargo install io-pipe

Use

Single thread usage example:

use std::io::{read_to_string, Write};

fn main() {
    let (mut writer, reader) = io_pipe::pipe();
    _ = writer.write("hello".as_bytes()).unwrap();
    drop(writer);

    assert_eq!("hello".to_string(), read_to_string(reader).unwrap());
}

Multi thread usage example:

use std::io::{read_to_string, Write};
use std::thread::spawn;
use io_pipe::pipe;

fn main() {
    let (mut writer, reader) = pipe();
    spawn({
        move || {
            _ = writer.write("hello".as_bytes()).unwrap();
        }
    });

    assert_eq!("hello".len(), read_to_string(reader).unwrap().len());
}

Contributing

Feel free for creating new PR. Use rustfmt and clippy checks before commiting.