Skip to main content

serve_connection

Function serve_connection 

Source
pub async fn serve_connection<R, W>(
    daemon: &Daemon,
    reader: &mut R,
    writer: &mut W,
) -> Result<(), WireError>
where R: AsyncRead + Unpin, W: AsyncWrite + Unpin,
Expand description

Drive one connection: handshake, then requests until the peer hangs up.

After the handshake the two directions are driven by two loops, and the first of them to finish ends the connection: the reader finishing means the peer hung up, the writer finishing means the transport failed, and neither is worth continuing half of. Cancelling the reader mid-frame is safe for exactly that reason — nothing is going to read the rest of it.