Remove some Unpin requirements on Futures (#1384)

* Remove lots of Unpin requirements

* Make Transport::and_then accept pinned futures

* Finish the PR

* Work on secio

* Fix BandwidthTransport

* Adjust ListenersStrema

* Fix nodes/tasks

* Fix nodes

* Various more fixes

* Fix yamux

* Fix Swarm

* Fix WebSockets

* Fix rw-stream-sink
This commit is contained in:
Pierre Krieger
2020-01-14 12:03:10 +01:00
committed by GitHub
parent 42a45e2630
commit 3f968cbf92
23 changed files with 249 additions and 216 deletions

View File

@ -86,7 +86,7 @@ where
upgrade: U,
},
Upgrade {
future: U::Future
future: Pin<Box<U::Future>>
},
Undefined
}
@ -102,7 +102,6 @@ impl<C, U> Future for InboundUpgradeApply<C, U>
where
C: AsyncRead + AsyncWrite + Unpin,
U: InboundUpgrade<Negotiated<C>>,
U::Future: Unpin,
{
type Output = Result<U::Output, UpgradeError<U::Error>>;
@ -118,7 +117,7 @@ where
}
};
self.inner = InboundUpgradeApplyState::Upgrade {
future: upgrade.upgrade_inbound(Compat01As03::new(io), info.0)
future: Box::pin(upgrade.upgrade_inbound(Compat01As03::new(io), info.0))
};
}
InboundUpgradeApplyState::Upgrade { mut future } => {
@ -163,7 +162,7 @@ where
upgrade: U
},
Upgrade {
future: U::Future
future: Pin<Box<U::Future>>
},
Undefined
}
@ -179,7 +178,6 @@ impl<C, U> Future for OutboundUpgradeApply<C, U>
where
C: AsyncRead + AsyncWrite + Unpin,
U: OutboundUpgrade<Negotiated<C>>,
U::Future: Unpin,
{
type Output = Result<U::Output, UpgradeError<U::Error>>;
@ -195,7 +193,7 @@ where
}
};
self.inner = OutboundUpgradeApplyState::Upgrade {
future: upgrade.upgrade_outbound(Compat01As03::new(connection), info.0)
future: Box::pin(upgrade.upgrade_outbound(Compat01As03::new(connection), info.0))
};
}
OutboundUpgradeApplyState::Upgrade { mut future } => {

View File

@ -144,7 +144,7 @@ pub trait InboundUpgrade<C>: UpgradeInfo {
/// Possible error during the handshake.
type Error;
/// Future that performs the handshake with the remote.
type Future: Future<Output = Result<Self::Output, Self::Error>> + Unpin;
type Future: Future<Output = Result<Self::Output, Self::Error>>;
/// After we have determined that the remote supports one of the protocols we support, this
/// method is called to start the handshake.
@ -184,7 +184,7 @@ pub trait OutboundUpgrade<C>: UpgradeInfo {
/// Possible error during the handshake.
type Error;
/// Future that performs the handshake with the remote.
type Future: Future<Output = Result<Self::Output, Self::Error>> + Unpin;
type Future: Future<Output = Result<Self::Output, Self::Error>>;
/// After we have determined that the remote supports one of the protocols we support, this
/// method is called to start the handshake.