expression
QUIC: read stream initiator and direction
The lowest two bits of a QUIC stream ID distinguish client/server initiation and bidirectional/unidirectional use. This example classifies small valid IDs; it does not allocate streams or validate a wire integer. Expected stdout (not executed): 0: client bidi 1: server bidi 2: client uni 3: server uni 4: client bidi Common mistake: Confusing HTTP/2 stream numbering with QUIC stream numbering.
Formal Syntax & Structure
rust syntaxrust
id & 1; id & 2Working Example
Example Snippetrust
fn main() { for id in [0_u64, 1, 2, 3, 4] { let initiator = if id & 1 == 0 { "client" } else { "server" }; let direction = if id & 2 == 0 { "bidi" } else { "uni" }; println!("{id}: {initiator} {direction}"); }}