Remove Unpin requirement for the send Buf

This commit is contained in:
Sean McArthur
2019-12-06 11:26:36 -08:00
parent 13e0f17a03
commit ec751f3696
12 changed files with 34 additions and 33 deletions

View File

@@ -281,7 +281,7 @@ impl<T, B> FramedWrite<T, B> {
}
}
impl<T: AsyncRead + Unpin, B: Unpin> AsyncRead for FramedWrite<T, B> {
impl<T: AsyncRead + Unpin, B> AsyncRead for FramedWrite<T, B> {
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [std::mem::MaybeUninit<u8>]) -> bool {
self.inner.prepare_uninitialized_buffer(buf)
}
@@ -303,6 +303,9 @@ impl<T: AsyncRead + Unpin, B: Unpin> AsyncRead for FramedWrite<T, B> {
}
}
// We never project the Pin to `B`.
impl<T: Unpin, B> Unpin for FramedWrite<T, B> {}
#[cfg(feature = "unstable")]
mod unstable {
use super::*;

View File

@@ -27,7 +27,7 @@ pub struct Codec<T, B> {
impl<T, B> Codec<T, B>
where
T: AsyncRead + AsyncWrite + Unpin,
B: Buf + Unpin,
B: Buf,
{
/// Returns a new `Codec` with the default max frame size
#[inline]
@@ -118,7 +118,7 @@ impl<T, B> Codec<T, B> {
impl<T, B> Codec<T, B>
where
T: AsyncWrite + Unpin,
B: Buf + Unpin,
B: Buf,
{
/// Returns `Ready` when the codec can buffer a frame
pub fn poll_ready(&mut self, cx: &mut Context) -> Poll<io::Result<()>> {
@@ -149,7 +149,6 @@ where
impl<T, B> Stream for Codec<T, B>
where
T: AsyncRead + Unpin,
B: Unpin,
{
type Item = Result<Frame, RecvError>;
@@ -161,7 +160,7 @@ where
impl<T, B> Sink<Frame<B>> for Codec<T, B>
where
T: AsyncWrite + Unpin,
B: Buf + Unpin,
B: Buf,
{
type Error = SendError;