File tree 2 files changed +35
-4
lines changed
2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 1
- use std:: io:: { self , Read , Write } ;
1
+ use std:: io:: { self , BufRead , Read , Write } ;
2
2
use std:: marker:: Unpin ;
3
3
use std:: pin:: Pin ;
4
4
use std:: task:: { Context , Poll } ;
5
5
6
- use futures_io:: { AsyncRead , AsyncWrite } ;
6
+ use futures_io:: { AsyncBufRead , AsyncRead , AsyncWrite } ;
7
7
8
8
#[ derive( Debug ) ]
9
9
pub ( crate ) struct StdAdapter < S > {
43
43
}
44
44
}
45
45
46
+ impl < S > BufRead for StdAdapter < S >
47
+ where
48
+ S : AsyncBufRead + Unpin ,
49
+ {
50
+ fn fill_buf ( & mut self ) -> io:: Result < & [ u8 ] > {
51
+ unimplemented ! ( )
52
+ // TODO: make it compile
53
+ // match self.with_context(|ctx, stream| stream.poll_fill_buf(ctx)) {
54
+ // Poll::Ready(buf) => buf,
55
+ // Poll::Pending => Err(io::Error::from(io::ErrorKind::WouldBlock)),
56
+ // }
57
+ }
58
+
59
+ fn consume ( & mut self , amt : usize ) {
60
+ self . consume ( amt)
61
+ }
62
+ }
63
+
46
64
impl < S > Write for StdAdapter < S >
47
65
where
48
66
S : AsyncWrite + Unpin ,
Original file line number Diff line number Diff line change 1
- use std:: io:: { self , Read , Write } ;
1
+ use std:: io:: { self , BufRead , Read , Write } ;
2
2
use std:: marker:: Unpin ;
3
3
use std:: pin:: Pin ;
4
4
use std:: ptr:: null_mut;
5
5
use std:: task:: { Context , Poll } ;
6
6
7
- use futures_io:: { AsyncRead , AsyncWrite } ;
7
+ use futures_io:: { AsyncBufRead , AsyncRead , AsyncWrite } ;
8
8
9
9
use crate :: std_adapter:: StdAdapter ;
10
10
64
64
}
65
65
}
66
66
67
+ impl < S > AsyncBufRead for TlsStream < S >
68
+ where
69
+ S : AsyncBufRead + AsyncWrite + Unpin ,
70
+ {
71
+ fn poll_fill_buf ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < io:: Result < & [ u8 ] > > {
72
+ self . with_context ( cx, |s| cvt ( s. fill_buf ( ) ) )
73
+ }
74
+
75
+ fn consume ( self : Pin < & mut Self > , amt : usize ) {
76
+ self . consume ( amt)
77
+ }
78
+ }
79
+
67
80
impl < S > AsyncWrite for TlsStream < S >
68
81
where
69
82
S : AsyncRead + AsyncWrite + Unpin ,
You can’t perform that action at this time.
0 commit comments