mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-21 10:43:25 +00:00
Move Deref impls for TlsSession closer to definition
This commit is contained in:
+19
-19
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user