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,
impl<P> QuicSession<P>where
P: Protocol,
Sourcepub fn new(connection: Connection) -> QuicSession<P>
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.
Sourcepub fn new_owned(connection: Connection, endpoint: Endpoint) -> QuicSession<P>
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.
Sourcepub fn connection(&self) -> &Connection
pub fn connection(&self) -> &Connection
The underlying connection.
Sourcepub fn endpoint(&self) -> Option<&Endpoint>
pub fn endpoint(&self) -> Option<&Endpoint>
The endpoint this session keeps alive, if it was given one.
Sourcepub fn without_datagrams(self) -> QuicSession<P>
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,
impl<P> Clone for QuicSession<P>where
P: Protocol,
Source§fn clone(&self) -> QuicSession<P>
fn clone(&self) -> QuicSession<P>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<P> Datagrams<P> for QuicSession<P>
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.
impl<P> Datagrams<P> for QuicSession<P>
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>
fn max_datagram_size(&self) -> Option<u32>
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,
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,
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,
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,
Source§impl<P> Debug for QuicSession<P>where
P: Protocol,
impl<P> Debug for QuicSession<P>where
P: Protocol,
Source§impl<P> Session<P> for QuicSession<P>
impl<P> Session<P> for QuicSession<P>
Source§fn capabilities(&self) -> Capabilities
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
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,
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,
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,
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>
type ClientLane = QuicTransport<P>
Source§type ServiceLane = QuicServiceLane<P>
type ServiceLane = QuicServiceLane<P>
Auto Trait Implementations§
impl<P> !RefUnwindSafe for QuicSession<P>
impl<P> !UnwindSafe for QuicSession<P>
impl<P> Freeze for QuicSession<P>
impl<P> Send for QuicSession<P>
impl<P> Sync for QuicSession<P>
impl<P> Unpin for QuicSession<P>
impl<P> UnsafeUnpin for QuicSession<P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
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,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more