pub struct OwnedWriteHalf { /* private fields */ }
Expand description
Owned write half of a UnixStream
, created by into_split
.
Note that in the AsyncWrite
implementation of this type,
poll_shutdown
will shut down the stream in the write direction.
Dropping the write half will also shut down the write half of the stream.
Writing to an OwnedWriteHalf
is usually done using the convenience methods
found on the AsyncWriteExt
trait.
Implementations
sourceimpl OwnedWriteHalf
impl OwnedWriteHalf
sourcepub fn reunite(self, other: OwnedReadHalf) -> Result<UnixStream, ReuniteError>
pub fn reunite(self, other: OwnedReadHalf) -> Result<UnixStream, ReuniteError>
Attempts to put the two halves of a UnixStream
back together and
recover the original socket. Succeeds only if the two halves
originated from the same call to into_split
.
sourcepub fn forget(self)
pub fn forget(self)
Destroys the write half, but don’t close the write half of the stream until the read half is dropped. If the read half has already been dropped, this closes the stream.
sourcepub async fn ready(&self, interest: Interest) -> Result<Ready>
pub async fn ready(&self, interest: Interest) -> Result<Ready>
Waits for any of the requested ready states.
This function is usually paired with try_read()
or try_write()
. It
can be used to concurrently read / write to the same socket on a single
task without splitting the socket.
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 WouldBlock
or
Poll::Pending
.
sourcepub async fn writable(&self) -> Result<()>
pub async fn writable(&self) -> Result<()>
Waits for the socket to become writable.
This function is equivalent to ready(Interest::WRITABLE)
and is usually
paired with try_write()
.
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 write that fails with WouldBlock
or
Poll::Pending
.
sourcepub fn try_write(&self, buf: &[u8]) -> Result<usize>
pub fn try_write(&self, buf: &[u8]) -> Result<usize>
Tries to write a buffer to the stream, returning how many bytes were written.
The function will attempt to write the entire contents of buf
, but
only part of the buffer may be written.
This function is usually paired with writable()
.
Return
If data is successfully written, Ok(n)
is returned, where n
is the
number of bytes written. If the stream is not ready to write data,
Err(io::ErrorKind::WouldBlock)
is returned.
sourcepub fn try_write_vectored(&self, buf: &[IoSlice<'_>]) -> Result<usize>
pub fn try_write_vectored(&self, buf: &[IoSlice<'_>]) -> Result<usize>
Tries to write several buffers to the stream, returning how many bytes were written.
Data is written from each buffer in order, with the final buffer read
from possible being only partially consumed. This method behaves
equivalently to a single call to try_write()
with concatenated
buffers.
This function is usually paired with writable()
.
Return
If data is successfully written, Ok(n)
is returned, where n
is the
number of bytes written. If the stream is not ready to write data,
Err(io::ErrorKind::WouldBlock)
is returned.
sourcepub fn peer_addr(&self) -> Result<SocketAddr>
pub fn peer_addr(&self) -> Result<SocketAddr>
Returns the socket address of the remote half of this connection.
sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the socket address of the local half of this connection.
Trait Implementations
sourceimpl AsRef<UnixStream> for OwnedWriteHalf
impl AsRef<UnixStream> for OwnedWriteHalf
sourcefn as_ref(&self) -> &UnixStream
fn as_ref(&self) -> &UnixStream
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl AsyncWrite for OwnedWriteHalf
impl AsyncWrite for OwnedWriteHalf
sourcefn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
Attempt to write bytes from buf
into the object. Read more
sourcefn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize>>
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize>>
Like poll_write
, except that it writes from a slice of buffers. Read more
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
Determines if this writer has an efficient poll_write_vectored
implementation. Read more
sourceimpl Debug for OwnedWriteHalf
impl Debug for OwnedWriteHalf
Auto Trait Implementations
impl RefUnwindSafe for OwnedWriteHalf
impl Send for OwnedWriteHalf
impl Sync for OwnedWriteHalf
impl Unpin for OwnedWriteHalf
impl UnwindSafe for OwnedWriteHalf
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more