From 8a488f2d7eb565d33daa5416ba57ce7b94f1401f Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 20 Dec 2024 11:43:40 +0100 Subject: [PATCH] proto: inline trivial constructor --- quinn-proto/src/token.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/quinn-proto/src/token.rs b/quinn-proto/src/token.rs index 59dcc5575..e8bcc9715 100644 --- a/quinn-proto/src/token.rs +++ b/quinn-proto/src/token.rs @@ -203,14 +203,6 @@ pub(crate) struct IncomingToken { } impl IncomingToken { - /// Construct for an `Incoming` which is not validated by a token - fn unvalidated(header: &InitialHeader) -> Self { - Self { - retry_src_cid: None, - orig_dst_cid: header.dst_cid, - } - } - /// Construct for an `Incoming` given the first packet header, or error if the connection /// cannot be established pub(crate) fn from_header( @@ -218,8 +210,13 @@ impl IncomingToken { server_config: &ServerConfig, remote_address: SocketAddr, ) -> Result { + let unvalidated = Self { + retry_src_cid: None, + orig_dst_cid: header.dst_cid, + }; + if header.token.is_empty() { - return Ok(Self::unvalidated(header)); + return Ok(unvalidated); } RetryToken::from_bytes( @@ -230,7 +227,7 @@ impl IncomingToken { ) .and_then(|token| token.validate(header, server_config)) .or_else(|e| match e { - ValidationError::Unusable => Ok(Self::unvalidated(header)), + ValidationError::Unusable => Ok(unvalidated), ValidationError::InvalidRetry => Err(InvalidRetryTokenError), }) }