Skip to main content

Module reader_writer

Module reader_writer 

Source
Expand description

Reader/writer task split helpers.

Splitting the per-peer endpoint into two cooperating Tokio tasks lets inbound decoding and outbound serialization overlap, removing the head-of-line blocking that the unified-loop design has under load.

This module ships the orchestrator that the EndpointManager plugs into. It does not own a transport — instead it accepts a RawTransport adapter so the same shape works for TcpTransport today and for the TLS variant once 5.E lands the wire integration.

Both tasks are tokio::spawn-ed; the orchestrator returns a ReaderWriterHandle that gives access to the outbound tx, the inbound rx, and a JoinHandle for shutdown coordination.

Structs§

ReaderWriterHandle
Handle returned by spawn_reader_writer. The orchestrator surfaces the outbound tx, the inbound rx, and per-task JoinHandles so the manager can await clean shutdown.

Traits§

RawTransport
Trait the orchestrator drives. The transport produces inbound frames on recv and accepts outbound frames on send. Either end signals graceful shutdown by returning None (read EOF) or Err(_) (write failure) — the orchestrator stops both tasks.

Functions§

spawn_reader_writer
Spawn a reader/writer pair around transport. The reader pumps inbound frames into a tokio::mpsc channel; the writer drains the outbound channel onto the wire. Either failure stops both.