Remove Unpin requirement for the send Buf
This commit is contained in:
@@ -336,7 +336,7 @@ pub(crate) struct Peer;
|
||||
|
||||
impl<B> SendRequest<B>
|
||||
where
|
||||
B: Buf + Unpin + 'static,
|
||||
B: Buf + 'static,
|
||||
{
|
||||
/// Returns `Ready` when the connection can initialize a new HTTP/2.0
|
||||
/// stream.
|
||||
@@ -566,7 +566,7 @@ where
|
||||
|
||||
impl<B> Future for ReadySendRequest<B>
|
||||
where
|
||||
B: Buf + Unpin + 'static,
|
||||
B: Buf + 'static,
|
||||
{
|
||||
type Output = Result<SendRequest<B>, crate::Error>;
|
||||
|
||||
@@ -1063,7 +1063,7 @@ impl Builder {
|
||||
) -> impl Future<Output = Result<(SendRequest<B>, Connection<T, B>), crate::Error>>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
B: Buf + Unpin + 'static,
|
||||
B: Buf + 'static,
|
||||
{
|
||||
Connection::handshake2(io, self.clone())
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ where
|
||||
impl<T, B> Connection<T, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
B: Buf + Unpin + 'static,
|
||||
B: Buf + 'static,
|
||||
{
|
||||
async fn handshake2(
|
||||
mut io: T,
|
||||
@@ -1229,7 +1229,7 @@ where
|
||||
impl<T, B> Future for Connection<T, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
B: Buf + Unpin + 'static,
|
||||
B: Buf + 'static,
|
||||
{
|
||||
type Output = Result<(), crate::Error>;
|
||||
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ impl<T, P, B> Connection<T, P, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
P: Peer,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
pub fn new(codec: Codec<T, Prioritized<B>>, config: Config) -> Connection<T, P, B> {
|
||||
let streams = Streams::new(streams::Config {
|
||||
@@ -394,7 +394,7 @@ where
|
||||
impl<T, B> Connection<T, server::Peer, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
pub fn next_incoming(&mut self) -> Option<StreamRef<B>> {
|
||||
self.streams.next_incoming()
|
||||
|
||||
@@ -128,7 +128,7 @@ impl GoAway {
|
||||
) -> Poll<Option<io::Result<Reason>>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
if let Some(frame) = self.pending.take() {
|
||||
if !dst.poll_ready(cx)?.is_ready() {
|
||||
|
||||
@@ -142,7 +142,7 @@ impl PingPong {
|
||||
) -> Poll<io::Result<()>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
if let Some(pong) = self.pending_pong.take() {
|
||||
if !dst.poll_ready(cx)?.is_ready() {
|
||||
@@ -165,7 +165,7 @@ impl PingPong {
|
||||
) -> Poll<io::Result<()>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
if let Some(ref mut ping) = self.pending_ping {
|
||||
if !ping.sent {
|
||||
|
||||
@@ -43,8 +43,8 @@ impl Settings {
|
||||
) -> Result<(), RecvError>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
C: Buf + Unpin,
|
||||
B: Buf,
|
||||
C: Buf,
|
||||
P: Peer,
|
||||
{
|
||||
if frame.is_ack() {
|
||||
@@ -100,8 +100,8 @@ impl Settings {
|
||||
) -> Poll<Result<(), RecvError>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
C: Buf + Unpin,
|
||||
B: Buf,
|
||||
C: Buf,
|
||||
P: Peer,
|
||||
{
|
||||
if let Some(settings) = &self.remote {
|
||||
|
||||
@@ -474,7 +474,7 @@ impl Prioritize {
|
||||
) -> Poll<io::Result<()>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
// Ensure codec is ready
|
||||
ready!(dst.poll_ready(cx))?;
|
||||
|
||||
@@ -846,7 +846,7 @@ impl Recv {
|
||||
) -> Poll<io::Result<()>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
if let Some(stream_id) = self.refused {
|
||||
ready!(dst.poll_ready(cx))?;
|
||||
@@ -918,7 +918,7 @@ impl Recv {
|
||||
) -> Poll<io::Result<()>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
// Send any pending connection level window updates
|
||||
ready!(self.send_connection_window_update(cx, dst))?;
|
||||
@@ -937,7 +937,7 @@ impl Recv {
|
||||
) -> Poll<io::Result<()>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
if let Some(incr) = self.flow.unclaimed_capacity() {
|
||||
let frame = frame::WindowUpdate::new(StreamId::zero(), incr);
|
||||
@@ -968,7 +968,7 @@ impl Recv {
|
||||
) -> Poll<io::Result<()>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
loop {
|
||||
// Ensure the codec has capacity
|
||||
|
||||
@@ -279,7 +279,7 @@ impl Send {
|
||||
) -> Poll<io::Result<()>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
self.prioritize
|
||||
.poll_complete(cx, buffer, store, counts, dst)
|
||||
|
||||
@@ -94,7 +94,7 @@ struct SendBuffer<B> {
|
||||
|
||||
impl<B, P> Streams<B, P>
|
||||
where
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
P: Peer,
|
||||
{
|
||||
pub fn new(config: Config) -> Self {
|
||||
@@ -596,7 +596,6 @@ where
|
||||
) -> Poll<io::Result<()>>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Unpin,
|
||||
{
|
||||
let mut me = self.inner.lock().unwrap();
|
||||
let me = &mut *me;
|
||||
|
||||
@@ -356,7 +356,7 @@ where
|
||||
impl<T, B> Connection<T, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
B: Buf + Unpin + 'static,
|
||||
B: Buf + 'static,
|
||||
{
|
||||
fn handshake2(io: T, builder: Builder) -> Handshake<T, B> {
|
||||
// Create the codec.
|
||||
@@ -523,7 +523,7 @@ where
|
||||
impl<T, B> futures_core::Stream for Connection<T, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
B: Buf + Unpin + 'static,
|
||||
B: Buf + 'static,
|
||||
{
|
||||
type Item = Result<(Request<RecvStream>, SendResponse<B>), crate::Error>;
|
||||
|
||||
@@ -921,7 +921,7 @@ impl Builder {
|
||||
pub fn handshake<T, B>(&self, io: T) -> Handshake<T, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
B: Buf + Unpin + 'static,
|
||||
B: Buf + 'static,
|
||||
{
|
||||
Connection::handshake2(io, self.clone())
|
||||
}
|
||||
@@ -1108,7 +1108,7 @@ impl<T, B: Buf> Flush<T, B> {
|
||||
impl<T, B> Future for Flush<T, B>
|
||||
where
|
||||
T: AsyncWrite + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
type Output = Result<Codec<T, B>, crate::Error>;
|
||||
|
||||
@@ -1137,7 +1137,7 @@ impl<T, B: Buf> ReadPreface<T, B> {
|
||||
impl<T, B> Future for ReadPreface<T, B>
|
||||
where
|
||||
T: AsyncRead + Unpin,
|
||||
B: Buf + Unpin,
|
||||
B: Buf,
|
||||
{
|
||||
type Output = Result<Codec<T, B>, crate::Error>;
|
||||
|
||||
@@ -1174,7 +1174,7 @@ where
|
||||
impl<T, B: Buf> Future for Handshake<T, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
B: Buf + Unpin + 'static,
|
||||
B: Buf + 'static,
|
||||
{
|
||||
type Output = Result<Connection<T, B>, crate::Error>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user