Wrap multistream-select streams under a Negotiated (#1001)

This commit is contained in:
Pierre Krieger
2019-03-19 17:27:30 +01:00
committed by GitHub
parent 63e9e39538
commit 96e559b503
24 changed files with 162 additions and 111 deletions

View File

@ -19,7 +19,7 @@
// DEALINGS IN THE SOFTWARE.
use futures::future::{self, FutureResult};
use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};
use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo, upgrade::Negotiated};
use std::iter;
use void::Void;
@ -36,21 +36,21 @@ impl UpgradeInfo for PlainTextConfig {
}
impl<C> InboundUpgrade<C> for PlainTextConfig {
type Output = C;
type Output = Negotiated<C>;
type Error = Void;
type Future = FutureResult<C, Self::Error>;
type Future = FutureResult<Negotiated<C>, Self::Error>;
fn upgrade_inbound(self, i: C, _: Self::Info) -> Self::Future {
fn upgrade_inbound(self, i: Negotiated<C>, _: Self::Info) -> Self::Future {
future::ok(i)
}
}
impl<C> OutboundUpgrade<C> for PlainTextConfig {
type Output = C;
type Output = Negotiated<C>;
type Error = Void;
type Future = FutureResult<C, Self::Error>;
type Future = FutureResult<Negotiated<C>, Self::Error>;
fn upgrade_outbound(self, i: C, _: Self::Info) -> Self::Future {
fn upgrade_outbound(self, i: Negotiated<C>, _: Self::Info) -> Self::Future {
future::ok(i)
}
}