Skip to main content

read_stdin

Function read_stdin 

Source
pub fn read_stdin() -> Result<Vec<u8>>
Expand description

Read all bytes from stdin into a Vec. On Linux, uses raw libc::read() to bypass Rust’s StdinLock/BufReader overhead. Uses a direct read() loop into a pre-allocated buffer instead of read_to_end(), which avoids Vec’s grow-and-probe pattern (extra read() calls and memcpy). Callers should enlarge the pipe buffer via fcntl(F_SETPIPE_SZ) before calling. Uses the full spare capacity for each read() to minimize syscalls.