pub struct AsyncIo<B>where
B: Backend,{ /* private fields */ }Expand description
TCP, UDP, local-pipe or stdio adapter with stable owned staging buffers.
Writes are buffered: poll_write reports bytes accepted into owned storage;
poll_flush, poll_close, or the next write waits for their native completion
and reports delayed errors. Flush before dropping to preserve buffered output.
Dropping cancels pending reads and writes and closes the owned loop handle.
A Pending poll never consumes the current write slice, so it may be replaced.
UDP writes accept one complete datagram or reject it if staging is too small;
UDP reads expose payload bytes without the sender address.
AsyncIo::poll_shutdown half-closes a stream: the write direction ends while
reads continue until the peer’s EOF, and the handle stays open until
poll_close or drop. poll_close still fully closes the handle.
Implementations§
Source§impl<B> AsyncIo<B>where
B: Backend,
impl<B> AsyncIo<B>where
B: Backend,
Sourcepub fn handle(&self) -> Handle
pub fn handle(&self) -> Handle
Borrow the underlying loop handle for configuration or address queries.
Sourcepub fn executor(&self) -> ExecutorHandle<B>
pub fn executor(&self) -> ExecutorHandle<B>
The executor that owns this stream’s handle, for deadlines and timers on the same loop (for example a lingering close). Cloning allocates nothing.
Sourcepub fn is_write_shut(&self) -> bool
pub fn is_write_shut(&self) -> bool
Whether AsyncIo::poll_shutdown has completed: writes now fail with
BrokenPipe, while reads continue until the peer’s EOF.
Sourcepub fn is_read_shut(&self) -> bool
pub fn is_read_shut(&self) -> bool
Whether receive shutdown completed for this adapter.
Sourcepub fn shutdown_receive(&mut self) -> Result<(), Error>
pub fn shutdown_receive(&mut self) -> Result<(), Error>
Stop receiving, discard this adapter’s buffered input, and preserve sends.
Calls native receive shutdown first; an unsupported transport leaves the adapter unchanged. After success all reads return EOF, including when a previous read was Pending or retained a partially consumed completion. Pending native access is cancelled, but its internal buffer remains owned by the executor until terminal acknowledgement. Repeated calls succeed. Supports TCP on Unix, Windows and WASI 0.2 and Unix-domain streams. WASI 0.3 and web currently return Unsupported; they require asynchronous stream cancellation before dropping the receive endpoint.
Sourcepub fn poll_shutdown(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Error>>
pub fn poll_shutdown(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Error>>
Gracefully end the write direction without closing the handle.
Flushes accepted writes first, then submits the backend’s stream shutdown
after them: TCP shutdown(SHUT_WR) on epoll/kqueue, shutdown(SD_SEND) on
IOCP, shutdown(send) on WASI 0.2 and closing the send stream on WASI 0.3.
The peer reads EOF after every byte written before it. Reads on this adapter
continue until the peer’s own EOF, so a server can drain unread peer input
instead of closing with bytes unread (which sends RST, and on macOS and
Windows discards data the peer has not read yet). Close or drop afterwards.
Repeated calls after completion return Ok. Transports that cannot
half-close return io::ErrorKind::Unsupported: UDP adapters, Windows named
pipes and console/synchronous handles, and non-socket Unix descriptors (ttys,
FIFOs, regular files). WASI stdout and stderr close their output stream; a
web WebSocket starts its close handshake. A pending poll never loses
progress: the submitted shutdown stays owned by this adapter until it
completes.
Trait Implementations§
Source§impl<B> AsyncRead for AsyncIo<B>where
B: Backend,
impl<B> AsyncRead for AsyncIo<B>where
B: Backend,
Source§impl<B> AsyncWrite for AsyncIo<B>where
B: Backend,
impl<B> AsyncWrite for AsyncIo<B>where
B: Backend,
Source§fn poll_write(
self: Pin<&mut AsyncIo<B>>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut AsyncIo<B>>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf into the object. Read moreSource§fn poll_flush(
self: Pin<&mut AsyncIo<B>>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut AsyncIo<B>>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§impl<B: Backend> HalfClose for AsyncIo<B>
impl<B: Backend> HalfClose for AsyncIo<B>
Source§fn executor(&self) -> Option<ExecutorHandle<B>>
fn executor(&self) -> Option<ExecutorHandle<B>>
None once the transport has been released.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<()>>
io::ErrorKind::Unsupported (see AsyncIo::poll_shutdown).