Move Deref impls for TlsSession closer to definition

This commit is contained in:
Dirkjan Ochtman
2019-05-23 05:50:07 +02:00
parent 069c6067c6
commit 7a588e151b
+19 -19
View File
@@ -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<Crypto>;
@@ -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];