If I want to write exactly n bytes, I can use: Write in std::io - Rust
For reading, I am a bit confused but which function to use here Read in std::io - Rust
I am expecting a function of signature
(&mut self, n: usize) -> Vec<u8> , but not seeing it.
Right now, what is the correct way to read n bytes and produce a Vec ? Am I supposed to:
let mut x = vec![0_u8; n]; // construct array of n bytes reader.read_exact(x.as_mut_ref()); return x;