@@ -2,9 +2,11 @@ use crate::{
2
2
connection:: { BaseConnection , Buffer } ,
3
3
utils:: { Error , READ_BUFFER_SIZE } ,
4
4
} ;
5
- use std:: time:: Duration ;
6
5
7
- use async_std:: { io, net:: Shutdown , net:: TcpStream , prelude:: * } ;
6
+ use async_std:: {
7
+ net:: { Shutdown , TcpStream } ,
8
+ prelude:: * ,
9
+ } ;
8
10
use async_trait:: async_trait;
9
11
10
12
pub struct InetSocketConnection {
@@ -33,8 +35,7 @@ impl BaseConnection for InetSocketConnection {
33
35
if let Err ( err) = result {
34
36
return Err ( Error :: Internal ( format ! ( "{}" , err) ) ) ;
35
37
}
36
- let client = result. unwrap ( ) ;
37
- self . client = Some ( client) ;
38
+ self . client = Some ( result. unwrap ( ) ) ;
38
39
39
40
self . connection_setup = true ;
40
41
Ok ( ( ) )
@@ -69,15 +70,14 @@ impl BaseConnection for InetSocketConnection {
69
70
let client = self . client . as_mut ( ) . unwrap ( ) ;
70
71
let mut buffer = Vec :: new ( ) ;
71
72
let mut read_size = READ_BUFFER_SIZE ;
72
-
73
73
while read_size > 0 {
74
74
let mut buf = [ 0u8 ; READ_BUFFER_SIZE ] ;
75
- let result = io :: timeout ( Duration :: from_millis ( 10 ) , client. read ( & mut buf) ) . await ;
75
+ let result = client. read ( & mut buf) . await ;
76
76
if result. is_err ( ) {
77
- return Some ( buffer ) ;
77
+ return None ;
78
78
}
79
79
read_size = result. unwrap ( ) ;
80
- buffer. extend ( buf[ ..read_size] . into_iter ( ) ) ;
80
+ buffer. extend ( buf[ ..read_size] . iter ( ) ) ;
81
81
}
82
82
Some ( buffer)
83
83
}
0 commit comments