Skip to main content

AnyRequest

Enum AnyRequest 

Source
pub enum AnyRequest {
    ControlPlane {
        request_id: VarInt,
        draft: DraftVersion,
    },
    Draft16(NamespaceStream),
    Draft17(RequestStream),
    Draft18(RequestStream),
    Draft19(RequestStream),
    Draft20(RequestStream),
}
Expand description

A request made through AnyConnection, in whichever form the negotiated draft carries it.

Drafts 07-15 put every request on the single bidirectional control stream, so all a requester keeps is the request ID it was allocated. Draft-16 moved one request off it: Section 3.3 there names “two uses of bidirectional streams, the control stream, which begins with CLIENT_SETUP, and SUBSCRIBE_NAMESPACE”, so a namespace subscription on that draft owns a stream and everything else does not. From draft-17 on every request does, and the stream is the correlation — responses on those drafts carry no request ID at all. The variants reflect that split rather than hiding it.

Hold on to this value for as long as the request is live. Dropping a per-request variant resets its stream, which the peer reads as a cancellation; dropping AnyRequest::ControlPlane does nothing, because there is no stream to reset.

The per-request variants are large — a RequestStream holds both halves of a QUIC stream — and ControlPlane is two small fields. That disparity is only visible when a single draft from 17 on is the only one enabled; with more than one, the largest variants are the same size as each other. Boxing them to close it would put an allocation on every request of every draft to flatter a build no released configuration uses.

Variants§

§

ControlPlane

Drafts 07-16: the request was written on the control stream and is identified only by its request ID.

Fields

§request_id: VarInt

The request ID the endpoint allocated.

§draft: DraftVersion

The draft that allocated it.

§

Draft16(NamespaceStream)

Draft-16: a namespace subscription, the one request on that draft that owns a bidirectional stream. Every other draft-16 request comes back as AnyRequest::ControlPlane.

§

Draft17(RequestStream)

Draft-17: the request owns a bidirectional stream.

§

Draft18(RequestStream)

Draft-18: the request owns a bidirectional stream.

§

Draft19(RequestStream)

Draft-19: the request owns a bidirectional stream.

§

Draft20(RequestStream)

Draft-20: the request owns a bidirectional stream.

Implementations§

Source§

impl AnyRequest

Source

pub fn request_id(&self) -> VarInt

The request ID this request was allocated.

Source

pub fn draft(&self) -> DraftVersion

The draft that carries this request.

Source

pub fn stream_id(&self) -> Option<u64>

The transport stream ID this request owns, or None on a draft that carries requests on the shared control stream.

This is the observable difference between the two variants: a caller that needs to correlate a response by stream — which is the only correlation drafts 17-19 offer — gets Some exactly when the draft provides one.

Source

pub fn cancel(&mut self, code: u64) -> Result<(), AnyConnectionError>

Cancel the request by resetting its stream with code.

Only a request that owns a stream can do this, which is a draft-16 namespace subscription and every request from draft-17 on. Cancelling a request that lives on the control stream means sending a message (UNSUBSCRIBE, FETCH_CANCEL, and so on), which needs the connection and is therefore not reachable from the request handle alone. There this refuses rather than silently doing nothing.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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, 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, !>

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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