From 7a588e151b2f2c91b50ee792fe00d8cc53ae796c Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 23 May 2019 05:50:07 +0200 Subject: [PATCH] Move Deref impls for TlsSession closer to definition --- quinn-proto/src/crypto.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/quinn-proto/src/crypto.rs b/quinn-proto/src/crypto.rs index e1bd21837..b595b5c81 100644 --- a/quinn-proto/src/crypto.rs +++ b/quinn-proto/src/crypto.rs @@ -101,6 +101,25 @@ impl CryptoSession for TlsSession { } } +impl Deref for TlsSession { + type Target = dyn Session; + fn deref(&self) -> &Self::Target { + match *self { + TlsSession::Client(ref session) => session, + TlsSession::Server(ref session) => session, + } + } +} + +impl DerefMut for TlsSession { + fn deref_mut(&mut self) -> &mut (dyn Session + 'static) { + match *self { + TlsSession::Client(ref mut session) => session, + TlsSession::Server(ref mut session) => session, + } + } +} + pub trait CryptoSession { fn alpn_protocol(&self) -> Option<&[u8]>; fn early_crypto(&self) -> Option; @@ -150,25 +169,6 @@ pub trait CryptoServerConfig { fn start_session(&self, params: &TransportParameters) -> Self::Session; } -impl Deref for TlsSession { - type Target = dyn Session; - fn deref(&self) -> &Self::Target { - match *self { - TlsSession::Client(ref session) => session, - TlsSession::Server(ref session) => session, - } - } -} - -impl DerefMut for TlsSession { - fn deref_mut(&mut self) -> &mut (dyn Session + 'static) { - match *self { - TlsSession::Client(ref mut session) => session, - TlsSession::Server(ref mut session) => session, - } - } -} - pub fn build_server_config() -> ServerConfig { let mut cfg = ServerConfig::new(NoClientAuth::new()); cfg.versions = vec![ProtocolVersion::TLSv1_3];