@@ -32,20 +32,20 @@ const SERVER_CHANNEL_SIZE: usize = 64;
3232pub enum ServerRunError {
3333 /// Incoming IO error
3434 #[ fail( display = "Incoming IO error: {:?}" , error) ]
35- IncomingError {
35+ Incoming {
3636 /// IO error
3737 #[ fail( cause) ]
3838 error : IoError
3939 } ,
4040 /// Ping wakeups timer error
4141 #[ fail( display = "Ping wakeups timer error: {:?}" , error) ]
42- PingWakeupsError {
42+ PingWakeups {
4343 /// Timer error
4444 error : TimerError
4545 } ,
4646 /// Send pings error
4747 #[ fail( display = "Send pings error: {:?}" , error) ]
48- SendPingsError {
48+ SendPings {
4949 /// Send pings error
5050 #[ fail( cause) ]
5151 error : IoError
@@ -57,58 +57,58 @@ pub enum ServerRunError {
5757pub enum ConnectionError {
5858 /// Error indicates that we couldn't get peer address
5959 #[ fail( display = "Failed to get peer address: {}" , error) ]
60- PeerAddrError {
60+ PeerAddr {
6161 /// Peer address error
6262 #[ fail( cause) ]
6363 error : IoError ,
6464 } ,
6565 /// Sending packet error
6666 #[ fail( display = "Failed to send TCP packet: {}" , error) ]
67- SendPacketError {
67+ SendPacket {
6868 error : EncodeError
6969 } ,
7070 /// Decode incoming packet error
7171 #[ fail( display = "Failed to decode incoming packet: {}" , error) ]
72- DecodePacketError {
72+ DecodePacket {
7373 error : DecodeError
7474 } ,
7575 /// Incoming IO error
7676 #[ fail( display = "Incoming IO error: {:?}" , error) ]
77- IncomingError {
77+ Incoming {
7878 /// IO error
7979 #[ fail( cause) ]
8080 error : IoError
8181 } ,
8282 /// Server handshake error
8383 #[ fail( display = "Server handshake error: {:?}" , error) ]
84- ServerHandshakeTimeoutError {
84+ ServerHandshakeTimeout {
8585 /// Server handshake error
8686 #[ fail( cause) ]
8787 error : tokio:: time:: error:: Elapsed
8888 } ,
8989 #[ fail( display = "Server handshake error: {:?}" , error) ]
90- ServerHandshakeIoError {
90+ ServerHandshakeIo {
9191 /// Server handshake error
9292 #[ fail( cause) ]
9393 error : IoError ,
9494 } ,
9595 /// Packet handling error
9696 #[ fail( display = "Packet handling error: {:?}" , error) ]
97- PacketHandlingError {
97+ PacketHandling {
9898 /// Packet handling error
9999 #[ fail( cause) ]
100100 error : IoError
101101 } ,
102102 /// Insert client error
103103 #[ fail( display = "Packet handling error: {:?}" , error) ]
104- InsertClientError {
104+ InsertClient {
105105 /// Insert client error
106106 #[ fail( cause) ]
107107 error : IoError
108108 } ,
109109
110110 #[ fail( display = "Packet handling error: {:?}" , error) ]
111- ShutdownError {
111+ Shutdown {
112112 /// Insert client error
113113 #[ fail( cause) ]
114114 error : IoError
@@ -123,7 +123,7 @@ pub async fn tcp_run(server: &Server, listener: TcpListener, dht_sk: SecretKey,
123123
124124 let connections_future = async {
125125 loop {
126- let ( stream, _) = listener. accept ( ) . await . map_err ( |error| ServerRunError :: IncomingError { error } ) ?;
126+ let ( stream, _) = listener. accept ( ) . await . map_err ( |error| ServerRunError :: Incoming { error } ) ?;
127127 if connections_count. load ( Ordering :: SeqCst ) < connections_limit {
128128 connections_count. fetch_add ( 1 , Ordering :: SeqCst ) ;
129129 let connections_count_c = connections_count. clone ( ) ;
@@ -156,7 +156,7 @@ pub async fn tcp_run(server: &Server, listener: TcpListener, dht_sk: SecretKey,
156156
157157 trace ! ( "Tcp server ping sender wake up" ) ;
158158 server. send_pings ( ) . await
159- . map_err ( |error| ServerRunError :: SendPingsError { error } ) ?;
159+ . map_err ( |error| ServerRunError :: SendPings { error } ) ?;
160160 }
161161 } ;
162162
@@ -170,7 +170,7 @@ pub async fn tcp_run(server: &Server, listener: TcpListener, dht_sk: SecretKey,
170170pub async fn tcp_run_connection ( server : & Server , stream : TcpStream , dht_sk : SecretKey , stats : Stats ) -> Result < ( ) , ConnectionError > {
171171 let addr = match stream. peer_addr ( ) {
172172 Ok ( addr) => addr,
173- Err ( error) => return Err ( ConnectionError :: PeerAddrError {
173+ Err ( error) => return Err ( ConnectionError :: PeerAddr {
174174 error
175175 } ) ,
176176 } ;
@@ -183,10 +183,10 @@ pub async fn tcp_run_connection(server: &Server, stream: TcpStream, dht_sk: Secr
183183 ) ;
184184 let ( stream, channel, client_pk) = match fut. await {
185185 Err ( error) => Err (
186- ConnectionError :: ServerHandshakeTimeoutError { error }
186+ ConnectionError :: ServerHandshakeTimeout { error }
187187 ) ,
188188 Ok ( Err ( error) ) => Err (
189- ConnectionError :: ServerHandshakeIoError { error }
189+ ConnectionError :: ServerHandshakeIo { error }
190190 ) ,
191191 Ok ( Ok ( res) ) => Ok ( res)
192192 } ?;
@@ -199,18 +199,18 @@ pub async fn tcp_run_connection(server: &Server, stream: TcpStream, dht_sk: Secr
199199
200200 // processor = for each Packet from client process it
201201 let processor = from_client
202- . map_err ( |error| ConnectionError :: DecodePacketError { error } )
202+ . map_err ( |error| ConnectionError :: DecodePacket { error } )
203203 . try_for_each ( |packet| {
204204 debug ! ( "Handle {:?} => {:?}" , client_pk, packet) ;
205205 server. handle_packet ( & client_pk, packet)
206- . map_err ( |error| ConnectionError :: PacketHandlingError { error } )
206+ . map_err ( |error| ConnectionError :: PacketHandling { error } )
207207 } ) ;
208208
209209 let writer = async {
210210 while let Some ( packet) = to_client_rx. next ( ) . await {
211211 trace ! ( "Sending TCP packet {:?} to {:?}" , packet, client_pk) ;
212212 to_client. send ( packet) . await
213- . map_err ( |error| ConnectionError :: SendPacketError {
213+ . map_err ( |error| ConnectionError :: SendPacket {
214214 error
215215 } ) ?;
216216 }
@@ -225,7 +225,7 @@ pub async fn tcp_run_connection(server: &Server, stream: TcpStream, dht_sk: Secr
225225 addr. port ( )
226226 ) ;
227227 server. insert ( client) . await
228- . map_err ( |error| ConnectionError :: InsertClientError { error } ) ?;
228+ . map_err ( |error| ConnectionError :: InsertClient { error } ) ?;
229229
230230 let r_processing = futures:: select! {
231231 res = processor. fuse( ) => res,
@@ -236,7 +236,7 @@ pub async fn tcp_run_connection(server: &Server, stream: TcpStream, dht_sk: Secr
236236
237237 server. shutdown_client ( & client_pk, addr. ip ( ) , addr. port ( ) )
238238 . await
239- . map_err ( |error| ConnectionError :: ShutdownError { error } ) ?;
239+ . map_err ( |error| ConnectionError :: Shutdown { error } ) ?;
240240
241241 r_processing
242242}
0 commit comments