#reader #non-blocking #pipe #stderr #o-nonblock #non-blocking-reader

nonblock

Read available data from file descriptors without blocking (e.g. sockets, streams, child stdout, named pipes)

2 unstable releases

0.2.0 Jun 26, 2022
0.1.0 Apr 25, 2016

#611 in Asynchronous

Download history 1047/week @ 2024-12-17 415/week @ 2024-12-24 671/week @ 2024-12-31 1663/week @ 2025-01-07 1765/week @ 2025-01-14 1741/week @ 2025-01-21 1639/week @ 2025-01-28 1463/week @ 2025-02-04 1764/week @ 2025-02-11 1785/week @ 2025-02-18 2302/week @ 2025-02-25 2242/week @ 2025-03-04 2477/week @ 2025-03-11 2064/week @ 2025-03-18 2084/week @ 2025-03-25 1508/week @ 2025-04-01

8,612 downloads per month
Used in 5 crates

MIT license

11KB
104 lines

Read available data from file descriptors without blocking

Useful for nonblocking reads from sockets, named pipes, and child stdout/stderr

Example

use std::io::Read;
use std::process::{Command, Stdio};
use std::time::Duration;
use nonblock::NonBlockingReader;

let mut child = Command::new("some-executable")
                        .stdout(Stdio::piped())
                        .spawn().unwrap();
let stdout = child.stdout.take().unwrap();
let mut noblock_stdout = NonBlockingReader::from_fd(stdout).unwrap();
while !noblock_stdout.is_eof() {
    let mut buf = String::new();
    noblock_stdout.read_available_to_string(&mut buf).unwrap();
    std::thread::sleep(Duration::from_secs(5));
}

nonblock-rs

Read available data from file descriptors without blocking

Documentation

Crates.io Build Status

Examples

See structure-stdio.rs for an example usage.

Build & Test

This project is built and tested with cargo:

cargo build
cargo test
cargo doc --no-deps

Pro-tip: before building docs, clone existing docs to track changes

git clone -b gh-pages git@github.com:anowell/nonblock-rs.git target/doc

Dependencies

~43KB