Struct ReadHalf
struct ReadHalf<'a>(_)
Borrowed read half of a UnixStream, created by split.
Reading from a ReadHalf is usually done using the convenience methods found on the
AsyncReadExt trait.
Implementations
impl ReadHalf<'_>
async fn ready(self: &Self, interest: Interest) -> Result<Ready>Wait for any of the requested ready states.
This function is usually paired with
try_read(). It can be used instead ofreadable()to check the returned ready set forReady::READABLEandReady::READ_CLOSEDevents.The function may complete without the socket being ready. This is a false-positive and attempting an operation will return with
io::ErrorKind::WouldBlock. The function can also return with an emptyReadyset, so you should always check the returned value and possibly wait again if the requested states are not set.This function is equivalent to
UnixStream::ready.Cancel safety
This method is cancel safe. Once a readiness event occurs, the method will continue to return immediately until the readiness event is consumed by an attempt to read or write that fails with
WouldBlockorPoll::Pending.async fn readable(self: &Self) -> Result<()>Waits for the socket to become readable.
This function is equivalent to
ready(Interest::READABLE)and is usually paired withtry_read().Cancel safety
This method is cancel safe. Once a readiness event occurs, the method will continue to return immediately until the readiness event is consumed by an attempt to read that fails with
WouldBlockorPoll::Pending.fn try_read(self: &Self, buf: &mut [u8]) -> Result<usize>Tries to read data from the stream into the provided buffer, returning how many bytes were read.
Receives any pending data from the socket but does not wait for new data to arrive. On success, returns the number of bytes read. Because
try_read()is non-blocking, the buffer does not have to be stored by the async task and can exist entirely on the stack.Usually,
readable()orready()is used with this function.Return
If data is successfully read,
Ok(n)is returned, wherenis the number of bytes read. Ifnis0, then it can indicate one of two scenarios:- The stream's read half is closed and will no longer yield data.
- The specified buffer was 0 bytes in length.
If the stream is not ready to read data,
Err(io::ErrorKind::WouldBlock)is returned.fn try_read_buf<B: BufMut>(self: &Self, buf: &mut B) -> Result<usize>Tries to read data from the stream into the provided buffer, advancing the buffer's internal cursor, returning how many bytes were read.
Receives any pending data from the socket but does not wait for new data to arrive. On success, returns the number of bytes read. Because
try_read_buf()is non-blocking, the buffer does not have to be stored by the async task and can exist entirely on the stack.Usually,
readable()orready()is used with this function.Return
If data is successfully read,
Ok(n)is returned, wherenis the number of bytes read.Ok(0)indicates the stream's read half is closed and will no longer yield data. If the stream is not ready to read datafn try_read_vectored(self: &Self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>Tries to read data from the stream into the provided buffers, returning how many bytes were read.
Data is copied to fill each buffer in order, with the final buffer written to possibly being only partially filled. This method behaves equivalently to a single call to
try_read()with concatenated buffers.Receives any pending data from the socket but does not wait for new data to arrive. On success, returns the number of bytes read. Because
try_read_vectored()is non-blocking, the buffer does not have to be stored by the async task and can exist entirely on the stack.Usually,
readable()orready()is used with this function.Return
If data is successfully read,
Ok(n)is returned, wherenis the number of bytes read.Ok(0)indicates the stream's read half is closed and will no longer yield data. If the stream is not ready to read dataErr(io::ErrorKind::WouldBlock)is returned.fn peer_addr(self: &Self) -> Result<SocketAddr>Returns the socket address of the remote half of this connection.
fn local_addr(self: &Self) -> Result<SocketAddr>Returns the socket address of the local half of this connection.
impl AsRef for ReadHalf<'_>
fn as_ref(self: &Self) -> &UnixStream
impl AsyncRead for ReadHalf<'_>
fn poll_read(self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>) -> Poll<Result<()>>
impl<'a> Debug for ReadHalf<'a>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<'a> Freeze for ReadHalf<'a>
impl<'a> RefUnwindSafe for ReadHalf<'a>
impl<'a> Send for ReadHalf<'a>
impl<'a> Sync for ReadHalf<'a>
impl<'a> Unpin for ReadHalf<'a>
impl<'a> UnsafeUnpin for ReadHalf<'a>
impl<'a> UnwindSafe for ReadHalf<'a>
impl<R> AsyncReadExt for ReadHalf<'a>
impl<T> Any for ReadHalf<'a>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for ReadHalf<'a>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for ReadHalf<'a>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for ReadHalf<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for ReadHalf<'a>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for ReadHalf<'a>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for ReadHalf<'a>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>