Skip to main content

StreamCtx

Struct StreamCtx 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§session_id: SessionId

The session identifier.

§side: ProxySide

The side the stream arrived on.

§stream_id: u64

The source stream’s transport-level identifier.

0 for every WebTransport streamSendStream::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: DraftVersion

The 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: bool

Whether 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 Capabilities

What is executable on this draft at this site.

Implementations§

Source§

impl<'a> StreamCtx<'a>

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a> Clone for StreamCtx<'a>

Source§

fn clone(&self) -> StreamCtx<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for StreamCtx<'a>

Source§

impl<'a> Debug for StreamCtx<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for StreamCtx<'a>

§

impl<'a> RefUnwindSafe for StreamCtx<'a>

§

impl<'a> Send for StreamCtx<'a>

§

impl<'a> Sync for StreamCtx<'a>

§

impl<'a> Unpin for StreamCtx<'a>

§

impl<'a> UnsafeUnpin for StreamCtx<'a>

§

impl<'a> UnwindSafe for StreamCtx<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more