DESCRIPTION read() attempts to read up to count bytes from file descriptor fd into the buffer starting at buf.
On files that support seeking, the read operation commences at the file offset, and the file offset is incremented by the number of bytes read. If the file offset is at or past the end of file, no bytes are read, and read() returns zero.
If count is zero, read() may detect the errors described below. In the absence of any errors, or if read() does not check for errors, a read() with a count of 0 returns zero and has no other effects.
According to POSIX.1, if count is greater than SSIZE_MAX, the result is implementation-defined; see NOTES for the upper limit on Linux.
Pull some bytes from this source into the specified buffer, returning how many bytes were read.
This function does not provide any guarantees about whether it blocks waiting for data, but if an object needs to block for a read and cannot, it will typically signal this via an [`Err`] return value.
Write a buffer into this writer, returning how many bytes were written.
This function will attempt to write the entire contents of `buf`, but the entire write might not succeed, or the write may also generate an error. A call to `write` represents *at most one* attempt to write to any wrapped object.
Calls to `write` are not guaranteed to block waiting for data to be written, and a write which would otherwise block can be indicated through an [`Err`] variant.
A `BufRead` is a type of `Read`er which has an internal buffer, allowing it to perform extra ways of reading.
For example, reading line-by-line is inefficient without using a buffer, so if you want to read by line, you'll need `BufRead`, which includes a [`read_line`] method as well as a [`lines`] iterator.
If you have something that implements [`Read`], you can use the [`BufReader` type][`BufReader`] to turn it into a `BufRead`.
For example, [`File`] implements [`Read`], but not `BufRead`. [`BufReader`] to the rescue!
pin_project! { /// A future which can be used to easily read available number of bytes to fill /// a buffer. /// /// Created by the [`read`] function. #[derive(Debug)] #[must_use = "futures do nothing unless you `.await` or poll them"] pubstructRead<'a, R: ?Sized> { reader: &'amut R, buf: &'amut [u8], // Make this future `!Unpin` for compatibility with async trait methods. #[pin] _pin: PhantomPinned, } }