diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index 8a067302c..51ca2855a 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -25,8 +25,8 @@ use crate::{ packet::{Header, InitialHeader, InitialPacket, LongType, Packet, PartialDecode, SpaceId}, range_set::ArrayRangeSet, shared::{ - ConnectionEvent, ConnectionEventInner, ConnectionId, EcnCodepoint, EndpointEvent, - EndpointEventInner, + ConnectionEvent, ConnectionEventInner, ConnectionId, DatagramConnectionEvent, EcnCodepoint, + EndpointEvent, EndpointEventInner, }, token::ResetToken, transport_parameters::TransportParameters, @@ -989,13 +989,13 @@ impl Connection { pub fn handle_event(&mut self, event: ConnectionEvent) { use self::ConnectionEventInner::*; match event.0 { - Datagram { + Datagram(DatagramConnectionEvent { now, remote, ecn, first_decode, remaining, - } => { + }) => { // If this packet could initiate a migration and we're a client or a server that // forbids migration, drop the datagram. This could be relaxed to heuristically // permit NAT-rebinding-like migration. @@ -3346,11 +3346,11 @@ impl Connection { #[cfg(test)] pub(crate) fn decode_packet(&self, event: &ConnectionEvent) -> Option> { let (first_decode, remaining) = match &event.0 { - ConnectionEventInner::Datagram { + ConnectionEventInner::Datagram(DatagramConnectionEvent { first_decode, remaining, .. - } => (first_decode, remaining), + }) => (first_decode, remaining), _ => return None, }; diff --git a/quinn-proto/src/endpoint.rs b/quinn-proto/src/endpoint.rs index 898cb4368..91cd58959 100644 --- a/quinn-proto/src/endpoint.rs +++ b/quinn-proto/src/endpoint.rs @@ -27,8 +27,8 @@ use crate::{ PartialDecode, PlainInitialHeader, }, shared::{ - ConnectionEvent, ConnectionEventInner, ConnectionId, EcnCodepoint, EndpointEvent, - EndpointEventInner, IssuedCid, + ConnectionEvent, ConnectionEventInner, ConnectionId, DatagramConnectionEvent, EcnCodepoint, + EndpointEvent, EndpointEventInner, IssuedCid, }, token::TokenDecodeError, transport_parameters::{PreferredAddress, TransportParameters}, @@ -192,13 +192,13 @@ impl Endpoint { if let Some(ch) = self.index.get(&addresses, &first_decode) { return Some(DatagramEvent::ConnectionEvent( ch, - ConnectionEvent(ConnectionEventInner::Datagram { + ConnectionEvent(ConnectionEventInner::Datagram(DatagramConnectionEvent { now, remote: addresses.remote, ecn, first_decode, remaining, - }), + })), )); } diff --git a/quinn-proto/src/shared.rs b/quinn-proto/src/shared.rs index a8bd274b2..ed40f33b0 100644 --- a/quinn-proto/src/shared.rs +++ b/quinn-proto/src/shared.rs @@ -11,17 +11,21 @@ pub struct ConnectionEvent(pub(crate) ConnectionEventInner); #[derive(Debug)] pub(crate) enum ConnectionEventInner { /// A datagram has been received for the Connection - Datagram { - now: Instant, - remote: SocketAddr, - ecn: Option, - first_decode: PartialDecode, - remaining: Option, - }, + Datagram(DatagramConnectionEvent), /// New connection identifiers have been issued for the Connection NewIdentifiers(Vec, Instant), } +/// Variant of [`ConnectionEventInner`]. +#[derive(Debug)] +pub(crate) struct DatagramConnectionEvent { + pub(crate) now: Instant, + pub(crate) remote: SocketAddr, + pub(crate) ecn: Option, + pub(crate) first_decode: PartialDecode, + pub(crate) remaining: Option, +} + /// Events sent from a Connection to an Endpoint #[derive(Debug)] pub struct EndpointEvent(pub(crate) EndpointEventInner);