@@ -19,7 +19,7 @@ use crate::{Acceptor, PeerAddress, Transport, TransportExt};
1919
2020pub mod config;
2121
22- /// An invalid operation, due to using as a server or viceversa.
22+ /// An invalid operation, due to using a client as a server or viceversa.
2323#[ derive( Debug , Clone , Copy , thiserror:: Error ) ]
2424pub enum InvalidOperation {
2525 #[ error( "tried to bind as a client" ) ]
@@ -48,9 +48,15 @@ pub enum Error {
4848}
4949
5050/// A TCP-TLS client.
51- #[ derive( Debug , Clone , From , Deref , DerefMut ) ]
51+ #[ derive( Debug , Clone , Deref , DerefMut ) ]
5252pub struct Client ( config:: Client ) ;
5353
54+ impl Client {
55+ pub fn new ( config : config:: Client ) -> Self {
56+ Self ( config)
57+ }
58+ }
59+
5460/// A TCP-TLS server.
5561pub struct Server {
5662 /// The underlying TCP listener.
@@ -59,6 +65,12 @@ pub struct Server {
5965 acceptor : Arc < SslAcceptor > ,
6066}
6167
68+ impl Server {
69+ pub fn new ( acceptor : SslAcceptor ) -> Self {
70+ Self { listener : None , acceptor : Arc :: new ( acceptor) }
71+ }
72+ }
73+
6274impl fmt:: Debug for Server {
6375 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
6476 f. debug_struct ( "Server" )
@@ -78,12 +90,12 @@ pub enum TcpTls {
7890impl TcpTls {
7991 /// Create a new instance of the transport with client configuration.
8092 pub fn new_client ( config : config:: Client ) -> Self {
81- TcpTls :: Client ( config . into ( ) )
93+ TcpTls :: Client ( Client :: new ( config ) )
8294 }
8395
8496 /// Create a new instance of the transport with server configuration.
8597 pub fn new_server ( config : config:: Server ) -> Self {
86- TcpTls :: Server ( Server { listener : None , acceptor : Arc :: new ( config. ssl_acceptor ) } )
98+ TcpTls :: Server ( Server :: new ( config. ssl_acceptor ) )
8799 }
88100
89101 pub fn as_client ( & self ) -> Option < & Client > {
0 commit comments