Add implementations of prepare_uninitialized_buffer and read_buf where relevant (#1107)

* Fix #1080

* Fix browser WebSockets
This commit is contained in:
Pierre Krieger
2019-05-10 11:26:18 +02:00
committed by GitHub
parent 089e349671
commit c2398adf67
19 changed files with 121 additions and 8 deletions

View File

@ -68,13 +68,19 @@ where
A: AsyncRead,
B: AsyncRead,
{
#[inline]
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [u8]) -> bool {
match self {
EitherOutput::First(a) => a.prepare_uninitialized_buffer(buf),
EitherOutput::Second(b) => b.prepare_uninitialized_buffer(buf),
}
}
fn read_buf<Bu: bytes::BufMut>(&mut self, buf: &mut Bu) -> Poll<usize, IoError> {
match self {
EitherOutput::First(a) => a.read_buf(buf),
EitherOutput::Second(b) => b.read_buf(buf),
}
}
}
impl<A, B> Read for EitherOutput<A, B>
@ -179,6 +185,13 @@ where
}
}
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [u8]) -> bool {
match self {
EitherOutput::First(ref inner) => inner.prepare_uninitialized_buffer(buf),
EitherOutput::Second(ref inner) => inner.prepare_uninitialized_buffer(buf),
}
}
fn read_substream(&self, sub: &mut Self::Substream, buf: &mut [u8]) -> Poll<usize, Self::Error> {
match (self, sub) {
(EitherOutput::First(ref inner), EitherOutput::First(ref mut sub)) => {