Roles in the QUIC protocol, including client and server.
The least significant bit (0x01) of the StreamId identifies the initiator role of the stream.
Client-initiated streams have even-numbered stream IDs (with the bit set to 0),
and server-initiated streams have odd-numbered stream IDs (with the bit set to 1).
See section-2.1-3
of QUIC.
As a protocol capable of multiplexing streams, QUIC is different from traditional
HTTP protocols for clients and servers.
In the QUIC protocol, it is not only the client that can actively open a new stream;
the server can also actively open a new stream to push some data to the client.
In fact, in a new stream, the server can initiate an HTTP3 request to the client,
and the client, upon receiving the request, responds back to the server.
In this case, the client surprisingly plays the role of the traditional “server”,
which is quite fascinating.
use qbase::role::Role;
let local = Role::Client;
let peer = !local;
let is_client = matches!(local, Role::Client); // true
let is_server = matches!(peer, Role::Server); // true