Skip to main content

HalfClose

Trait HalfClose 

Source
pub trait HalfClose: Stream {
    type Backend: Backend;

    // Required methods
    fn executor(&self) -> Option<ExecutorHandle<Self::Backend>>;
    fn poll_shutdown(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
    ) -> Poll<Result<()>>;
}
Expand description

A stream whose write direction can end while its read direction stays open.

futures-io’s poll_close releases the whole transport. A half-close instead sends the peer EOF and keeps reading, which a server needs for a lingering close: closing a socket with unread peer bytes sends RST, and a received RST discards data the peer has not read yet on macOS and Windows. AsyncIo, turnloop_tls::asynchronous::TlsStream and Transport implement it.

Required Associated Types§

Source

type Backend: Backend

Backend of the executor that owns the native handle.

Required Methods§

Source

fn executor(&self) -> Option<ExecutorHandle<Self::Backend>>

The executor owning the native handle, whose timers bound a lingering close. None once the transport has been released.

Source

fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Flush accepted writes, then end the write direction without closing the handle (TLS sends close_notify first). Reads continue until the peer’s EOF; later writes fail. Completed shutdowns stay complete on repeated polls. Transports without a separate write direction return io::ErrorKind::Unsupported (see AsyncIo::poll_shutdown).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§