use std::future::{ready, Ready}; use libp2p_core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use libp2p_swarm::{Stream, StreamProtocol}; pub struct Upgrade { pub(crate) supported_protocols: Vec, } impl UpgradeInfo for Upgrade { type Info = StreamProtocol; type InfoIter = std::vec::IntoIter; fn protocol_info(&self) -> Self::InfoIter { self.supported_protocols.clone().into_iter() } } impl InboundUpgrade for Upgrade { type Output = (Stream, StreamProtocol); type Error = void::Void; type Future = Ready>; fn upgrade_inbound(self, socket: Stream, info: Self::Info) -> Self::Future { ready(Ok((socket, info))) } } impl OutboundUpgrade for Upgrade { type Output = (Stream, StreamProtocol); type Error = void::Void; type Future = Ready>; fn upgrade_outbound(self, socket: Stream, info: Self::Info) -> Self::Future { ready(Ok((socket, info))) } }