pub struct InitialQuicConnection<Tx, M>{ /* private fields */ }Expand description
A QUIC connection that has not performed a handshake yet.
This type is currently only used for server-side connections. It is created and added to the listener’s connection stream after an initial packet from a client has been received and (optionally) the client’s IP address has been validated.
To turn the initial connection into a fully established one, a QUIC handshake must be performed. Users have multiple options to facilitate this:
startis a simple entrypoint which spawns a task to handle the entire lifetime of the QUIC connection. The caller can then only communicate with the connection via theirApplicationOverQuic.handshakespawns a task for the handshake and awaits its completion. Afterwards, it pauses the connection and allows the caller to resume it later via an opaque struct. We spawn a separate task to allow the tokio scheduler free choice in where to run the handshake.handshake_futreturns a future to drive the handshake for maximum flexibility.
Implementations§
Source§impl<Tx, M> InitialQuicConnection<Tx, M>
impl<Tx, M> InitialQuicConnection<Tx, M>
Sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
The local address this connection listens on.
Sourcepub fn peer_addr(&self) -> SocketAddr
pub fn peer_addr(&self) -> SocketAddr
The remote address for this connection.
Sourcepub fn audit_log_stats(&self) -> Arc<QuicAuditStats>
pub fn audit_log_stats(&self) -> Arc<QuicAuditStats>
A handle to the QuicAuditStats for this connection.
§Note
These stats are updated during the lifetime of the connection. The getter exists to grab a handle early on, which can then be stowed away and read out after the connection has closed.
Sourcepub fn stats(&self) -> &Arc<Mutex<QuicConnectionStats>>
pub fn stats(&self) -> &Arc<Mutex<QuicConnectionStats>>
A handle to the QuicConnectionStats for this connection.
§Note
Initially, these stats represent the state when the quiche::Connection was created. They are updated when the connection is closed, so this getter exists primarily to grab a handle early on.
Sourcepub fn handshake_fut<A: ApplicationOverQuic>(
self,
app: A,
) -> (QuicConnection, BoxFuture<'static, Result<Running<Arc<Tx>, M, A>>>)
pub fn handshake_fut<A: ApplicationOverQuic>( self, app: A, ) -> (QuicConnection, BoxFuture<'static, Result<Running<Arc<Tx>, M, A>>>)
Creates a future to drive the connection’s handshake.
This is a lower-level alternative to the handshake function which
gives the caller more control over execution of the future. See
handshake for details on the return values.
Sourcepub async fn handshake<A: ApplicationOverQuic>(
self,
app: A,
) -> Result<(QuicConnection, Running<Arc<Tx>, M, A>)>
pub async fn handshake<A: ApplicationOverQuic>( self, app: A, ) -> Result<(QuicConnection, Running<Arc<Tx>, M, A>)>
Performs the QUIC handshake in a separate tokio task and awaits its completion.
The returned QuicConnection holds metadata about the established
connection. The connection itself is paused after handshake
returns and must be resumed by passing the opaque Running value to
InitialQuicConnection::resume. This two-step process
allows callers to collect telemetry and run code before serving their
ApplicationOverQuic.
Sourcepub fn resume<A: ApplicationOverQuic>(pre_running: Running<Arc<Tx>, M, A>)
pub fn resume<A: ApplicationOverQuic>(pre_running: Running<Arc<Tx>, M, A>)
Resumes a QUIC connection which was paused after a successful handshake.
Sourcepub fn start<A: ApplicationOverQuic>(self, app: A) -> QuicConnection
pub fn start<A: ApplicationOverQuic>(self, app: A) -> QuicConnection
Drives a QUIC connection from handshake to close in separate tokio tasks.
It combines InitialQuicConnection::handshake and
InitialQuicConnection::resume into a single call.
Trait Implementations§
Source§impl<Tx, M> AsSocketStats for InitialQuicConnection<Tx, M>
impl<Tx, M> AsSocketStats for InitialQuicConnection<Tx, M>
fn as_socket_stats(&self) -> SocketStats
fn as_quic_stats(&self) -> Option<&Arc<QuicAuditStats>>
Source§impl<Tx, M> ShutdownConnection for InitialQuicConnection<Tx, M>
impl<Tx, M> ShutdownConnection for InitialQuicConnection<Tx, M>
Auto Trait Implementations§
impl<Tx, M> Freeze for InitialQuicConnection<Tx, M>
impl<Tx, M> !RefUnwindSafe for InitialQuicConnection<Tx, M>
impl<Tx, M> Send for InitialQuicConnection<Tx, M>where
Tx: ?Sized,
impl<Tx, M> Sync for InitialQuicConnection<Tx, M>where
Tx: ?Sized,
impl<Tx, M> Unpin for InitialQuicConnection<Tx, M>where
Tx: ?Sized,
impl<Tx, M> !UnwindSafe for InitialQuicConnection<Tx, M>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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