Skip to main content

read_fd

Function read_fd 

Source
pub fn read_fd(fd: RawFd, buf: &mut [u8]) -> Result<usize>
Expand description

Read from a raw fd into buf, returning the number of bytes read.

A thin safe wrapper over read(2) so a forbid(unsafe_code) driver can pull frames off a non-socket fd (e.g. a TUN/TAP device, which is not a UdpSocket and so has no std read method available through this crate’s callers). A would-block condition surfaces as io::ErrorKind::WouldBlock.