mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-14 18:41:22 +00:00
Add implementations of prepare_uninitialized_buffer and read_buf where relevant (#1107)
* Fix #1080 * Fix browser WebSockets
This commit is contained in:
@ -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)) => {
|
||||
|
Reference in New Issue
Block a user