Skip to content

Commit 735b091

Browse files
skeleton
1 parent 9eeaa9c commit 735b091

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

src/std_adapter.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use std::io::{self, Read, Write};
1+
use std::io::{self, BufRead, Read, Write};
22
use std::marker::Unpin;
33
use std::pin::Pin;
44
use std::task::{Context, Poll};
55

6-
use futures_io::{AsyncRead, AsyncWrite};
6+
use futures_io::{AsyncBufRead, AsyncRead, AsyncWrite};
77

88
#[derive(Debug)]
99
pub(crate) struct StdAdapter<S> {
@@ -43,6 +43,24 @@ where
4343
}
4444
}
4545

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+
4664
impl<S> Write for StdAdapter<S>
4765
where
4866
S: AsyncWrite + Unpin,

src/tls_stream.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::io::{self, Read, Write};
1+
use std::io::{self, BufRead, Read, Write};
22
use std::marker::Unpin;
33
use std::pin::Pin;
44
use std::ptr::null_mut;
55
use std::task::{Context, Poll};
66

7-
use futures_io::{AsyncRead, AsyncWrite};
7+
use futures_io::{AsyncBufRead, AsyncRead, AsyncWrite};
88

99
use crate::std_adapter::StdAdapter;
1010

@@ -64,6 +64,19 @@ where
6464
}
6565
}
6666

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+
6780
impl<S> AsyncWrite for TlsStream<S>
6881
where
6982
S: AsyncRead + AsyncWrite + Unpin,

0 commit comments

Comments
 (0)