Expand description

Bulk operations performed on streams

By representing stream operations as structs, callers can request multiple tasks to be performed in a single call, which reduces context switching.

Consider the following scenario where we send 3 chunks of data and finish the stream:

stream.send(a).await?;
stream.send(b).await?;
stream.send(c).await?;
stream.finish().await?;

This will result in at least 4 context switches (and potentially even more if the stream is currently blocked on sending).

Using the bulk operation API greatly reduces this amount:

stream
    .request()
    .send(&mut [a, b, c])
    .finish()
    .await?;

Modules

Request and response related to receiving on a stream

Request and response related to transmitting on a stream

Structs

A request made on a stream

A response received after executing a request

Enums