cs_mwc_libp2p_swarm/protocols_handler/
dummy.rs1use crate::NegotiatedSubstream;
22use crate::protocols_handler::{
23 KeepAlive,
24 SubstreamProtocol,
25 ProtocolsHandler,
26 ProtocolsHandlerEvent,
27 ProtocolsHandlerUpgrErr
28};
29use mwc_libp2p_core::{Multiaddr, upgrade::{InboundUpgrade, OutboundUpgrade, DeniedUpgrade}};
30use std::task::{Context, Poll};
31use void::Void;
32
33#[derive(Clone, Debug)]
35pub struct DummyProtocolsHandler {
36 pub keep_alive: KeepAlive,
37}
38
39impl Default for DummyProtocolsHandler {
40 fn default() -> Self {
41 DummyProtocolsHandler {
42 keep_alive: KeepAlive::No
43 }
44 }
45}
46
47impl ProtocolsHandler for DummyProtocolsHandler {
48 type InEvent = Void;
49 type OutEvent = Void;
50 type Error = Void;
51 type InboundProtocol = DeniedUpgrade;
52 type OutboundProtocol = DeniedUpgrade;
53 type OutboundOpenInfo = Void;
54 type InboundOpenInfo = ();
55
56 fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
57 SubstreamProtocol::new(DeniedUpgrade, ())
58 }
59
60 fn inject_fully_negotiated_inbound(
61 &mut self,
62 _: <Self::InboundProtocol as InboundUpgrade<NegotiatedSubstream>>::Output,
63 _: Self::InboundOpenInfo
64 ) {
65 }
66
67 fn inject_fully_negotiated_outbound(
68 &mut self,
69 _: <Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Output,
70 _: Self::OutboundOpenInfo
71 ) {
72 }
73
74 fn inject_event(&mut self, _: Self::InEvent) {}
75
76 fn inject_address_change(&mut self, _: &Multiaddr) {}
77
78 fn inject_dial_upgrade_error(&mut self, _: Self::OutboundOpenInfo, _: ProtocolsHandlerUpgrErr<<Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Error>) {}
79
80 fn inject_listen_upgrade_error(&mut self, _: Self::InboundOpenInfo, _: ProtocolsHandlerUpgrErr<<Self::InboundProtocol as InboundUpgrade<NegotiatedSubstream>>::Error>) {}
81
82 fn connection_keep_alive(&self) -> KeepAlive {
83 self.keep_alive
84 }
85
86 fn poll(
87 &mut self,
88 _: &mut Context<'_>,
89 ) -> Poll<
90 ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent, Self::Error>,
91 > {
92 Poll::Pending
93 }
94}