fix fix msrv

This commit is contained in:
Rob Ede 2021-04-21 16:36:06 +01:00
parent 3433e7711d
commit 4261cab3a5
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
3 changed files with 26 additions and 8 deletions

View File

@ -7,7 +7,7 @@ use std::{
};
use bytes::{Bytes, BytesMut};
use futures_core::Stream;
use futures_core::{ready, Stream};
use crate::error::Error;
@ -72,7 +72,11 @@ impl MessageBody for Body {
Poll::Ready(Some(Ok(mem::take(bin))))
}
}
Body::Message(body) => body.as_mut().poll_next(cx).map_err(Into::into),
Body::Message(body) => match ready!(body.as_mut().poll_next(cx)) {
Some(Err(err)) => Poll::Ready(Some(Err(err.into()))),
Some(Ok(val)) => Poll::Ready(Some(Ok(val))),
None => Poll::Ready(None),
},
}
}
}
@ -212,6 +216,10 @@ impl MessageBody for BoxAnyBody {
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Bytes, Self::Error>>> {
self.0.as_mut().poll_next(cx).map_err(Into::into)
match ready!(self.0.as_mut().poll_next(cx)) {
Some(Err(err)) => Poll::Ready(Some(Err(err.into()))),
Some(Ok(val)) => Poll::Ready(Some(Ok(val))),
None => Poll::Ready(None),
}
}
}

View File

@ -7,6 +7,7 @@ use std::{
};
use bytes::{Bytes, BytesMut};
use futures_core::ready;
use pin_project_lite::pin_project;
use crate::error::Error;
@ -212,9 +213,14 @@ where
) -> Poll<Option<Result<Bytes, Self::Error>>> {
let this = self.as_mut().project();
this.body.poll_next(cx).map_err(|err| {
let f = self.as_mut().project().mapper.take().unwrap();
(f)(err)
})
match ready!(this.body.poll_next(cx)) {
Some(Err(err)) => {
let f = self.as_mut().project().mapper.take().unwrap();
let mapped_err = (f)(err);
Poll::Ready(Some(Err(mapped_err)))
}
Some(Ok(val)) => Poll::Ready(Some(Ok(val))),
None => Poll::Ready(None),
}
}
}

View File

@ -120,7 +120,11 @@ impl<B: MessageBody<Error = Error>> MessageBody for EncoderBody<B> {
}
EncoderBodyProj::Stream(b) => b.poll_next(cx),
EncoderBodyProj::BoxedStream(ref mut b) => {
b.as_mut().poll_next(cx).map_err(Into::into)
match ready!(b.as_mut().poll_next(cx)) {
Some(Err(err)) => Poll::Ready(Some(Err(err.into()))),
Some(Ok(val)) => Poll::Ready(Some(Ok(val))),
None => Poll::Ready(None),
}
}
}
}