From 724cc1b1e6cbab8305a698f7cb2853acfcc89ffa Mon Sep 17 00:00:00 2001 From: Prabhav Parashar Date: Mon, 10 Jul 2023 22:03:26 -0400 Subject: [PATCH 1/2] exposing more methods on wtransport::Connection from underlying quinn::Connection object --- wtransport/src/connection.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/wtransport/src/connection.rs b/wtransport/src/connection.rs index ad80d55..de4dfb0 100644 --- a/wtransport/src/connection.rs +++ b/wtransport/src/connection.rs @@ -7,6 +7,7 @@ use crate::stream::OpeningUniStream; use crate::stream::RecvStream; use crate::stream::SendStream; use std::net::SocketAddr; +use std::time::Duration; use wtransport_proto::ids::SessionId; /// A WebTransport session connection. @@ -114,4 +115,33 @@ impl Connection { pub fn remote_address(&self) -> SocketAddr { self.quic_connection.remote_address() } + + /// A stable identifier for this connection + /// + /// Peer addresses and connection IDs can change, but this value will remain + /// fixed for the lifetime of the connection. + #[inline(always)] + pub fn stable_id(&self) -> usize { + self.quic_connection.stable_id() + } + + /// Compute the maximum size of datagrams that may be passed to [`send_datagram()`]. + /// + /// Returns `None` if datagrams are unsupported by the peer or disabled locally. + /// + /// This may change over the lifetime of a connection according to variation in the path MTU + /// estimate. The peer can also enforce an arbitrarily small fixed limit, but if the peer's + /// limit is large this is guaranteed to be a little over a kilobyte at minimum. + /// + /// Not necessarily the maximum size of received datagrams. + #[inline(always)] + pub fn max_datagram_size(&self) -> Option { + self.quic_connection.max_datagram_size() + } + + /// Current best estimate of this connection's latency (round-trip-time) + #[inline(always)] + pub fn rtt(&self) -> Duration { + self.quic_connection.rtt() + } } From 25ed7140fab852fd34c0c6f3bc15427adc91f221 Mon Sep 17 00:00:00 2001 From: Prabhav Parashar Date: Tue, 11 Jul 2023 17:08:13 -0400 Subject: [PATCH 2/2] fixing nits --- wtransport/src/connection.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wtransport/src/connection.rs b/wtransport/src/connection.rs index de4dfb0..fbcdaf8 100644 --- a/wtransport/src/connection.rs +++ b/wtransport/src/connection.rs @@ -116,7 +116,7 @@ impl Connection { self.quic_connection.remote_address() } - /// A stable identifier for this connection + /// A stable identifier for this connection. /// /// Peer addresses and connection IDs can change, but this value will remain /// fixed for the lifetime of the connection. @@ -125,7 +125,7 @@ impl Connection { self.quic_connection.stable_id() } - /// Compute the maximum size of datagrams that may be passed to [`send_datagram()`]. + /// Compute(s) the maximum size of datagrams that may be passed to [`send_datagram()`]. /// /// Returns `None` if datagrams are unsupported by the peer or disabled locally. /// @@ -139,7 +139,7 @@ impl Connection { self.quic_connection.max_datagram_size() } - /// Current best estimate of this connection's latency (round-trip-time) + /// Current best estimate of this connection's latency (round-trip-time). #[inline(always)] pub fn rtt(&self) -> Duration { self.quic_connection.rtt()