pub fn split<S: AsyncRead + AsyncWrite + Unpin>(
stream: S,
) -> (ReadHalf<S>, WriteHalf<S>)Expand description
Split a bidirectional stream into independently-owned read and write halves.
Each half is Send + 'static (given the stream is), so the two can be driven by separate
futures/tasks — e.g. a reader loop and a writer loop running concurrently — without one holding
a &mut to the whole stream.
The halves share the stream behind a lock that is held only for the duration of a single
poll_read/poll_write/poll_flush/poll_close. Because reads and writes touch different
directions of the socket they never truly contend on data, only on this short critical section.
This is a runtime-agnostic split over the AsyncRead + AsyncWrite traits; a reactor that exposes
an owned, lock-free split of its own stream type can offer that separately.