From 57cc936d026454b408b877d33fddae0a24e02002 Mon Sep 17 00:00:00 2001 From: zephyr Date: Wed, 27 Apr 2022 21:05:05 +0900 Subject: [PATCH] add debug trait for tls connector/acceptor --- kaminari/src/mix.rs | 4 ++-- kaminari/src/tls.rs | 23 ++++++++++++++++++++++- kaminari/src/ws.rs | 6 +++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/kaminari/src/mix.rs b/kaminari/src/mix.rs index 2c8dbbe..6a4e124 100644 --- a/kaminari/src/mix.rs +++ b/kaminari/src/mix.rs @@ -14,7 +14,7 @@ pub struct MixClientConf { pub tls: Option, } -#[derive(Clone)] +#[derive(Debug, Clone)] pub enum MixConnect { Plain(NopConnect), Ws(WsConnect), @@ -76,7 +76,7 @@ pub struct MixServerConf { pub tls: Option, } -#[derive(Clone)] +#[derive(Debug, Clone)] pub enum MixAccept { Plain(NopAccept), Ws(WsAccept), diff --git a/kaminari/src/tls.rs b/kaminari/src/tls.rs index 912c7a8..0c21186 100644 --- a/kaminari/src/tls.rs +++ b/kaminari/src/tls.rs @@ -1,7 +1,7 @@ use std::io::Result; use std::future::Future; use std::sync::Arc; -use std::fmt::{Display, Formatter}; +use std::fmt::{Debug, Display, Formatter}; use super::{IOStream, AsyncAccept, AsyncConnect}; @@ -46,6 +46,18 @@ where fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "[tls]{}", self.conn) } } +impl Debug for TlsConnect +where + T: Debug, +{ + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("TlsConnect") + .field("conn", &self.conn) + .field("sni", &self.sni) + .finish() + } +} + impl TlsConnect { pub fn new(conn: T, conf: TlsClientConf) -> Self { let TlsClientConf { @@ -151,6 +163,15 @@ where fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "[tls]{}", self.lis) } } +impl Debug for TlsAccept +where + T: Debug, +{ + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("TlsAccept").field("lis", &self.lis).finish() + } +} + impl TlsAccept { pub fn new(lis: T, conf: TlsServerConf) -> Self { let TlsServerConf { diff --git a/kaminari/src/ws.rs b/kaminari/src/ws.rs index 0970bcd..f227659 100644 --- a/kaminari/src/ws.rs +++ b/kaminari/src/ws.rs @@ -28,13 +28,13 @@ impl Display for WsConf { } // =========== client ========== -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] pub struct Simple {} -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] pub struct Standard {} -#[derive(Clone, Copy)] +#[derive(Debug, Clone, Copy)] pub struct Fixed {} pub trait Mode {