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];