Skip to content

Releases: kkharji/process-stream

v0.3.0

25 Jun 20:28
0957462
Compare
Choose a tag to compare
feat: ProcessExt

v0.2.3

17 Jun 03:15
c0098bc
Compare
Choose a tag to compare

Support writing to process

#[tokio::main]
async fn main() -> io::Result<()> {
    let mut process: Process = Process::new("sort");

    // Set stdin (by default is set to null)
    process.stdin(Stdio::piped());

    // Get Stream;
    let mut stream = process.spawn_and_stream().unwrap();

    // Get writer from stdin;
    let mut writer = process.take_stdin().unwrap();

    // Spawn new async task and move stream to it
    let reader_thread = tokio::spawn(async move {
        while let Some(output) = stream.next().await {
            if output.is_exit() {
                println!("DONE")
            } else {
                println!("{output}")
            }
        }
    });

    // Spawn new async task and move writer to it
    let writer_thread = tokio::spawn(async move {
        writer.write(b"b\nc\na\n").await.unwrap();
        writer.write(b"f\ne\nd\n").await.unwrap();
    });

    // Wait till all threads finish
    writer_thread.await.unwrap();
    reader_thread.await.unwrap();


    Ok(())
}

Full Changelog: v0.2.2...v0.2.3

v0.2.2

26 May 14:18
7fea734
Compare
Choose a tag to compare
chore(release): 0.2.2

v0.2.0

23 May 08:12
4bfeb10
Compare
Choose a tag to compare

depreciate stream in favor of spawn_and_stream

v0.1.3

21 May 20:54
e4a924c
Compare
Choose a tag to compare
chore: re-export Stream

v0.1.2

21 May 20:32
601108a
Compare
Choose a tag to compare
chore: release

v0.1.1

21 May 20:16
53f83e9
Compare
Choose a tag to compare
feat: impl Deref for ProcessItem

had to change Exit inner type to string to avid leaking

v0.1.0

21 May 19:20
fc427fa
Compare
Choose a tag to compare
chore: Cargo.toml