Skip to main content

QuicSession

Struct QuicSession 

Source
pub struct QuicSession<P>
where P: Protocol,
{ /* private fields */ }
Expand description

A JetStream session over a QUIC connection.

Cloning is cheap and every clone addresses the same connection, so lanes can be opened from several tasks at once. The connection closes when the last clone goes away.

Implementations§

Source§

impl<P> QuicSession<P>
where P: Protocol,

Source

pub fn new(connection: Connection) -> QuicSession<P>

Wrap a connection whose endpoint the caller keeps alive.

The session takes ownership of the connection’s lifetime: when the last handle is dropped the connection closes, even if the caller holds a clone of it.

Source

pub fn new_owned(connection: Connection, endpoint: Endpoint) -> QuicSession<P>

Wrap a connection and keep endpoint alive alongside it.

Use this whenever the caller does not otherwise hold the endpoint the connection came from — returning a session from a helper that built its own crate::Client, say. A quinn::Endpoint closes every connection made from it when its last handle drops, so a session built with Self::new in that position is unusable before the caller ever sees it.

Source

pub fn connection(&self) -> &Connection

The underlying connection.

Source

pub fn endpoint(&self) -> Option<&Endpoint>

The endpoint this session keeps alive, if it was given one.

Source

pub fn without_datagrams(self) -> QuicSession<P>

Report this session as carrying no datagrams.

r[impl jetstream.session.capabilities] Session::capabilities derives datagram support from Connection::max_datagram_size, which reads the peer’s advertised limit and the path MTU. It is silent about this endpoint’s own configuration: a connection built with datagram_receive_buffer_size(None) still reports a size, while every send fails with Disabled and nothing can arrive.

quinn 0.11 documents max_size as returning None when datagrams are “disabled locally”, and its implementation does not check — so trusting the doc is how this goes wrong. quinn exposes no way to read the setting back from a Connection, so the caller that turned datagrams off says so here.

The override is shared by every handle on this connection, including clones taken before the call: a clone that went on claiming datagrams work would recreate exactly the mismatch this is here to prevent.

Trait Implementations§

Source§

impl<P> Clone for QuicSession<P>
where P: Protocol,

Source§

fn clone(&self) -> QuicSession<P>

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<P> Datagrams<P> for QuicSession<P>
where P: Protocol<Error = Error> + 'static, <P as Protocol>::Request: 'static, <P as Protocol>::Response: 'static,

r[impl jetstream.session.datagrams] QUIC datagrams belong to the connection, not to any stream on it. Only the raw channel is bound here; framing is the model’s, so both peers agree on it.

Source§

fn max_datagram_size(&self) -> Option<u32>

The largest frame the path will carry, if the transport knows it.
Source§

fn send_datagram_bytes<'life0, 'async_trait>( &'life0 self, bytes: Bytes, ) -> Pin<Box<dyn Future<Output = Result<(), SessionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, QuicSession<P>: 'async_trait,

Send one already-encoded datagram, or fail. Never fragmented, never retried.
Source§

fn recv_datagram_bytes<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Bytes, SessionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, QuicSession<P>: 'async_trait,

Receive the next datagram that arrived intact. Read more
Source§

fn send_request_datagram<'life0, 'async_trait>( &'life0 self, frame: Frame<<P as Protocol>::Request>, ) -> Pin<Box<dyn Future<Output = Result<(), SessionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Send a request, as the caller.
Source§

fn send_response_datagram<'life0, 'async_trait>( &'life0 self, frame: Frame<<P as Protocol>::Response>, ) -> Pin<Box<dyn Future<Output = Result<(), SessionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Send a response, as the callee.
Source§

impl<P> Debug for QuicSession<P>
where P: Protocol,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<P> Session<P> for QuicSession<P>
where P: Protocol<Error = Error> + 'static,

Source§

fn capabilities(&self) -> Capabilities

r[impl jetstream.session.capabilities] r[impl jetstream.session.capabilities.degradation] The conformance row says QUIC can carry datagrams. This connection may not: a peer that never advertised DATAGRAM support, or a transport configuration with them switched off, leaves max_datagram_size empty and every send failing with Disabled or UnsupportedByPeer. A capability is what this session has, not what its transport is capable of in general — reporting the row unconditionally would let require(Capability::Datagrams) succeed on a session that cannot carry one.

Source§

fn context(&self) -> Context

r[impl jetstream.session.identity.addressing] A certificate authenticates the peer once reached; the address is what reaches it, so both are reported.

Source§

fn open_lane<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<<QuicSession<P> as Session<P>>::ClientLane, SessionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, QuicSession<P>: 'async_trait,

r[impl jetstream.lane.independence] Every lane is its own QUIC stream, so one lane’s stalled frame does not delay another’s.

Source§

fn accept_lane<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<<QuicSession<P> as Session<P>>::ServiceLane, SessionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, QuicSession<P>: 'async_trait,

r[impl jetstream.session.symmetric] Either peer may open a lane on a QUIC connection.

Source§

fn close<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, QuicSession<P>: 'async_trait,

r[impl jetstream.session.lifetime] Closing the connection resets every stream opened on it, so lanes terminate with the session and calls in flight on them fail rather than hang.

Source§

type ClientLane = QuicTransport<P>

The end of a lane this peer opened, driven as the RPC caller.
Source§

type ServiceLane = QuicServiceLane<P>

The end of a lane the peer opened, served as the RPC callee.

Auto Trait Implementations§

§

impl<P> !RefUnwindSafe for QuicSession<P>

§

impl<P> !UnwindSafe for QuicSession<P>

§

impl<P> Freeze for QuicSession<P>
where PhantomData<fn() -> P>: Freeze,

§

impl<P> Send for QuicSession<P>
where PhantomData<fn() -> P>: Send,

§

impl<P> Sync for QuicSession<P>
where PhantomData<fn() -> P>: Sync,

§

impl<P> Unpin for QuicSession<P>
where PhantomData<fn() -> P>: Unpin,

§

impl<P> UnsafeUnpin for QuicSession<P>
where PhantomData<fn() -> P>: UnsafeUnpin,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<D> OwoColorize for D

§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either [OwoColorize::fg] or a color-specific method, such as [OwoColorize::green], Read more
§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either [OwoColorize::bg] or a color-specific method, such as [OwoColorize::on_yellow], Read more
§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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