pub type Duplex = Stream<Reader, Writer>;Expand description
One endpoint of an in-memory duplex connection, ready for a client or server.
Aliased Type§
pub struct Duplex { /* private fields */ }Implementations§
Source§impl Duplex
impl Duplex
Sourcepub fn into_halves(self) -> (Reader, Writer)
pub fn into_halves(self) -> (Reader, Writer)
Takes the reader and writer out of the stream without closing either half.
Each half closes its own direction on drop. Dropping the writer lets the
peer drain accepted output before EOF; dropping the reader refuses further
peer writes. Obtain a crate::transport::Closer with Self::closer before splitting
if you need to shut down both halves from another thread.
The stream’s write timeout is discarded. Any deadlines already installed on the halves are retained; new halves have no deadline until configured.
use darkbio_wire::memory;
use darkbio_wire::transport::Client;
let (host, bus) = memory::duplex(64 * 1024);
let (reader, writer) = bus.into_halves();
let client = Client::new(host);
// Move `reader` and `writer` to the bus's input and output pumps.