Skip to main content

Read

Trait Read 

Source
pub trait Read {
    // Required method
    fn read(&self, fd: Fd, buffer: &mut [u8]) -> Result<usize>;
}
Expand description

Trait for reading from file descriptors

Required Methods§

Source

fn read(&self, fd: Fd, buffer: &mut [u8]) -> Result<usize>

Reads from the file descriptor.

This is a thin wrapper around the read system call. If successful, returns the number of bytes read.

This function may perform blocking I/O, especially if the O_NONBLOCK flag is not set for the FD. Use SharedSystem::read_async to support concurrent I/O in an async function context.

TODO: This function should return a Future to support simulating blocking I/O in virtual systems.

Implementors§

Source§

impl Read for RealSystem

Source§

impl Read for VirtualSystem

Source§

impl<T: Read> Read for SharedSystem<T>

Delegates Read methods to the contained implementor.