A rough approximation of std::io::Read.
Attempts to read some bytes into
buf and returns the number of bytes read.
A return value of Ok(0) means that the end of the stream was reached.
Unlike with std::io::Read, implementations are expected to handle EINTR (i.e. std::io::ErrorKind::Interrupted) internally, by looping until either success is achieved or some other error is hit.