pub fn read_some_stdin(
input: &mut StdinLock<'_>,
buf: &mut BufferSlice,
) -> RUMResult<usize>Expand description
Consumes the incoming buffer in chunks of BUFFER_CHUNK_SIZE bytes size.
ยงExample
use std::io::stdin;
use std::io::prelude::*;
use std::process::{Command, Stdio};
use rumtk_core::cli::cli_utils::{read_some_stdin, BUFFER_SIZE, BUFFER_CHUNK_SIZE};
let mut stdin_lock = stdin().lock();
let mut stdin_buffer: Vec<u8> = Vec::with_capacity(BUFFER_SIZE);
let mut s = read_some_stdin(&mut stdin_lock, &mut stdin_buffer).unwrap();
let mut totas_s = s;
while s > 0 {
s = read_some_stdin(&mut stdin_lock, &mut stdin_buffer).unwrap();
totas_s += s;
}
assert_eq!(totas_s, 0, "Returned data with {} size even though we expected 0 bytes!", totas_s)