Skip to content

Commit

Permalink
add debug trait for tls connector/acceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrchien committed Apr 27, 2022
1 parent f75d704 commit 57cc936
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions kaminari/src/mix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct MixClientConf {
pub tls: Option<TlsClientConf>,
}

#[derive(Clone)]
#[derive(Debug, Clone)]
pub enum MixConnect {
Plain(NopConnect),
Ws(WsConnect<NopConnect>),
Expand Down Expand Up @@ -76,7 +76,7 @@ pub struct MixServerConf {
pub tls: Option<TlsServerConf>,
}

#[derive(Clone)]
#[derive(Debug, Clone)]
pub enum MixAccept {
Plain(NopAccept),
Ws(WsAccept<NopAccept>),
Expand Down
23 changes: 22 additions & 1 deletion kaminari/src/tls.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -46,6 +46,18 @@ where
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "[tls]{}", self.conn) }
}

impl<T> Debug for TlsConnect<T>
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<T> TlsConnect<T> {
pub fn new(conn: T, conf: TlsClientConf) -> Self {
let TlsClientConf {
Expand Down Expand Up @@ -151,6 +163,15 @@ where
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "[tls]{}", self.lis) }
}

impl<T> Debug for TlsAccept<T>
where
T: Debug,
{
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TlsAccept").field("lis", &self.lis).finish()
}
}

impl<T> TlsAccept<T> {
pub fn new(lis: T, conf: TlsServerConf) -> Self {
let TlsServerConf {
Expand Down
6 changes: 3 additions & 3 deletions kaminari/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 57cc936

Please sign in to comment.