pub type UniStream = UniSocket<StreamTy>;Expand description
A UniSocket used as a stream.
Aliased Type§
pub struct UniStream { /* private fields */ }Implementations§
Source§impl UniStream
impl UniStream
Sourcepub async fn peek(&mut self, buf: &mut [MaybeUninit<u8>]) -> Result<usize>
pub async fn peek(&mut self, buf: &mut [MaybeUninit<u8>]) -> Result<usize>
Receives data on the socket from the remote adress to which it is connected, without removing that data from the queue. On success, returns the number of bytes peeked.
Successive calls return the same data. This is accomplished by passing
MSG_PEEK as a flag to the underlying recv system call.
Sourcepub fn poll_peek(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<Result<usize>>
pub fn poll_peek( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<usize>>
Receives data on the socket from the remote adress to which it is connected, without removing that data from the queue. On success, returns the number of bytes peeked.
Successive calls return the same data. This is accomplished by passing
MSG_PEEK as a flag to the underlying recv system call.
Notes that on multiple calls to poll_peek, only
the waker from the Context passed to the most recent call is
scheduled to receive a wakeup. Unless you are implementing your own
future accepting connections, you probably want to use the asynchronous
accept method instead.
Sourcepub async fn read(&mut self, buf: &mut [MaybeUninit<u8>]) -> Result<usize>
pub async fn read(&mut self, buf: &mut [MaybeUninit<u8>]) -> Result<usize>
Receives data on the socket from the remote address to which it is connected.
§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 write(&mut self, buf: &[u8]) -> Result<usize>
pub async fn write(&mut self, buf: &[u8]) -> Result<usize>
Sends data on the socket to a connected peer.
§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 fn shutdown(&mut self, shutdown: Shutdown) -> Result<()>
pub fn shutdown(&mut self, shutdown: Shutdown) -> Result<()>
Shuts down the read, write, or both halves of this connection.
This function will cause all pending and future I/O on the specified portions to return immediately with an appropriate value.
Sourcepub fn into_split(self) -> (OwnedReadHalf, OwnedWriteHalf)
pub fn into_split(self) -> (OwnedReadHalf, OwnedWriteHalf)
Splits a UniStream into a read half and a write half, which can be
used to read and write the stream concurrently.
Note: dropping the write half will shutdown the write half of the stream.
Trait Implementations§
Source§impl AsyncRead for UniStream
impl AsyncRead for UniStream
Source§fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<Result<()>>
fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<()>>
Receives data on the socket from the remote address to which it is connected.
Notes that on multiple calls to poll_read, only
the waker from the Context passed to the most recent call is
scheduled to receive a wakeup. Unless you are implementing your own
future accepting connections, you probably want to use the asynchronous
read method instead.
Source§impl AsyncWrite for UniStream
impl AsyncWrite for UniStream
Source§fn 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>>
Sends data on the socket to a connected peer.
Notes that on multiple calls to poll_write, only
the waker from the Context passed to the most recent call is
scheduled to receive a wakeup. Unless you are implementing your own
future accepting connections, you probably want to use the asynchronous
write method instead.
Source§fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<()>>
For TCP and Unix domain sockets, flush is a no-op.
Source§fn poll_shutdown(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
) -> Poll<Result<()>>
fn poll_shutdown( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<()>>
See shutdown.
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
poll_write, except that it writes from a slice of buffers. Read moreSource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read more