#[non_exhaustive]pub struct StreamCtx<'a> {
pub session_id: SessionId,
pub side: ProxySide,
pub stream_id: u64,
pub draft: DraftVersion,
pub is_control_stream: bool,
pub caps: &'a Capabilities,
/* private fields */
}Expand description
Context for a stream open, stream header, or stream end decision.
At ProxyHook::on_stream_open this is deliberately track-blind:
the peer stream is opened before the first byte of the source stream is
read, so no track alias, group or subgroup is known. To reject a stream
by track, return StreamAction::Open there and decide in
ProxyHook::on_stream_header, which runs before the header’s bytes
are forwarded.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.session_id: SessionIdThe session identifier.
side: ProxySideThe side the stream arrived on.
stream_id: u64The source stream’s transport-level identifier.
0 for every WebTransport stream — SendStream::stream_id() and
RecvStream::stream_id() both return the constant on that arm. Use
it to correlate with the transport-level events in
crate::event; use Self::key to identify the stream.
draft: DraftVersionThe draft this stream is being parsed under. See
FrameCtx::draft for what settles it and when.
ProxyHook::on_stream_header always carries the settled answer:
its stream waits for one before it frames a byte, because the draft
decides where an object ends. ProxyHook::on_stream_open and
ProxyHook::on_stream_end read it without waiting — the first runs
before the stream has been read at all, so there is nothing it could
wait for that the session has not already asked of the control
stream — so on the moq-00 cohort a stream opened before any SETUP
was readable is offered here under the draft the session started on.
is_control_stream: boolWhether the control stream’s rules apply to this stream. It is the flag that selects those rules, not a claim about which QUIC stream this is, and on two of the three sites the difference is visible. Read it as a reset here is a protocol violation, which is what every site uses it for.
At ProxyHook::on_stream_end on drafts 17-19 it is true for a
bidirectional request stream as well as for the control stream.
Those drafts carry the control plane on a pair of unidirectional
streams and carry requests on bidirectional ones (draft-17 Section
3.3), and both are forwarded through the same control-message
framing, so both run under the control stream’s end-of-stream rules
and Action::ResetStream is refused on both. Draft-17 Section
3.3.1 permits a request to be cancelled by resetting its stream, so
refusing is stricter than the draft requires; it is the conservative
direction, nothing is destroyed that the draft would have kept, and
it is what crate::capability publishes. A hook that needs to tell
the two apart on those drafts cannot do it from this flag.
At ProxyHook::on_stream_open on drafts 17-19 it is false for
the unidirectional control stream. That site runs before the
stream’s type varint has been read, which is the only thing that says
what the stream is, so at that point nothing knows. One consequence
is worth stating plainly: StreamAction::Reject returned there may
land on a control stream, and no refusal reports it, because the site
had nothing to refuse it on.
On drafts 07-16 the control stream is the first client-initiated
bidirectional stream, it never reaches on_stream_open at all, and
this flag means exactly what its name says at every site.
caps: &'a CapabilitiesWhat is executable on this draft at this site.
Implementations§
Source§impl<'a> StreamCtx<'a>
impl<'a> StreamCtx<'a>
Sourcepub fn new(
session_id: SessionId,
side: ProxySide,
stream_id: u64,
draft: DraftVersion,
is_control_stream: bool,
caps: &'a Capabilities,
key: StreamKey,
) -> Self
pub fn new( session_id: SessionId, side: ProxySide, stream_id: u64, draft: DraftVersion, is_control_stream: bool, caps: &'a Capabilities, key: StreamKey, ) -> Self
Build a context. Field order matches the struct.
key is the stream’s session-local identity; the session mints one
per accepted stream and hands the same key to all three stream
sites, which is what makes Self::key a name a later stream can
serialize behind.
Sourcepub fn key(&self) -> StreamKey
pub fn key(&self) -> StreamKey
This stream’s session-local identity, for naming it later.
The value to hand
StreamAction::SerializeAfter
so a different stream waits for this one. Stable across
ProxyHook::on_stream_open, ProxyHook::on_stream_header and
ProxyHook::on_stream_end for one stream, unique for the
session’s lifetime, and never reused.
Not Self::stream_id: that is the transport id, which is the
constant 0 on every WebTransport stream, so keying on it would
collapse every WT stream of a side onto one entry and make
SerializeAfter attach a stream to an arbitrary sibling — or to
itself, which is a self-deadlock that degrades to a max_hold
stall. See StreamKey.