pub struct SwarmBuilder<Provider, Phase> { /* private fields */ }
Expand description
Build a Swarm
by combining an identity, a set of
Transport
s and a
NetworkBehaviour
.
let swarm = SwarmBuilder::with_new_identity()
.with_tokio()
.with_tcp(
Default::default(),
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)?
.with_quic()
.with_other_transport(|_key| DummyTransport::<(PeerId, StreamMuxerBox)>::new())?
.with_dns()?
.with_websocket(
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)
.await?
.with_relay_client(
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)?
.with_behaviour(|_key, relay| MyBehaviour { relay })?
.with_swarm_config(|cfg| {
// Edit cfg here.
cfg
})
.build();
Implementations§
Source§impl<T: AuthenticatedMultiplexedTransport, Provider, R> SwarmBuilder<Provider, BandwidthLoggingPhase<T, R>>
impl<T: AuthenticatedMultiplexedTransport, Provider, R> SwarmBuilder<Provider, BandwidthLoggingPhase<T, R>>
pub fn with_bandwidth_logging( self, ) -> (SwarmBuilder<Provider, BandwidthMetricsPhase<impl AuthenticatedMultiplexedTransport, R>>, Arc<BandwidthSinks>)
with_bandwidth_metrics
instead.pub fn without_bandwidth_logging( self, ) -> SwarmBuilder<Provider, BandwidthMetricsPhase<T, R>>
Source§impl<Provider, T: AuthenticatedMultiplexedTransport, R> SwarmBuilder<Provider, BandwidthLoggingPhase<T, R>>
impl<Provider, T: AuthenticatedMultiplexedTransport, R> SwarmBuilder<Provider, BandwidthLoggingPhase<T, R>>
pub fn with_bandwidth_metrics( self, registry: &mut Registry, ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, R>>
metrics
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthLoggingPhase<T, Behaviour>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthLoggingPhase<T, Behaviour>>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair, Behaviour) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
relay
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthLoggingPhase<T, NoRelayBehaviour>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthLoggingPhase<T, NoRelayBehaviour>>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
Source§impl<T: AuthenticatedMultiplexedTransport, Provider, R> SwarmBuilder<Provider, BandwidthMetricsPhase<T, R>>
impl<T: AuthenticatedMultiplexedTransport, Provider, R> SwarmBuilder<Provider, BandwidthMetricsPhase<T, R>>
pub fn with_bandwidth_metrics( self, registry: &mut Registry, ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, R>>
metrics
only.Source§impl<T, Provider, R> SwarmBuilder<Provider, BandwidthMetricsPhase<T, R>>
impl<T, Provider, R> SwarmBuilder<Provider, BandwidthMetricsPhase<T, R>>
pub fn without_bandwidth_metrics( self, ) -> SwarmBuilder<Provider, BehaviourPhase<T, R>>
Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthMetricsPhase<T, Behaviour>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthMetricsPhase<T, Behaviour>>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair, Behaviour) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
relay
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthMetricsPhase<T, NoRelayBehaviour>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthMetricsPhase<T, NoRelayBehaviour>>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
Source§impl<T, Provider> SwarmBuilder<Provider, BehaviourPhase<T, Behaviour>>
impl<T, Provider> SwarmBuilder<Provider, BehaviourPhase<T, Behaviour>>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair, Behaviour) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
relay
only.Source§impl<T, Provider> SwarmBuilder<Provider, BehaviourPhase<T, NoRelayBehaviour>>
impl<T, Provider> SwarmBuilder<Provider, BehaviourPhase<T, NoRelayBehaviour>>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
Source§impl<Provider, T: AuthenticatedMultiplexedTransport, B: NetworkBehaviour> SwarmBuilder<Provider, BuildPhase<T, B>>
impl<Provider, T: AuthenticatedMultiplexedTransport, B: NetworkBehaviour> SwarmBuilder<Provider, BuildPhase<T, B>>
Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, DnsPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, DnsPhase<T>>
pub fn with_dns( self, ) -> Result<SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>
async-std
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, DnsPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, DnsPhase<T>>
pub fn with_dns( self, ) -> Result<SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>
tokio
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, DnsPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, DnsPhase<T>>
pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts, ) -> SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>
async-std
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, DnsPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, DnsPhase<T>>
pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts, ) -> SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>
tokio
and crate feature dns
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, DnsPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, DnsPhase<T>>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
Source§impl SwarmBuilder<NoProviderSpecified, IdentityPhase>
impl SwarmBuilder<NoProviderSpecified, IdentityPhase>
pub fn with_new_identity() -> SwarmBuilder<NoProviderSpecified, ProviderPhase>
pub fn with_existing_identity( keypair: Keypair, ) -> SwarmBuilder<NoProviderSpecified, ProviderPhase>
Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>
pub fn with_other_transport<Muxer: StreamMuxer + Send + 'static, OtherTransport: Transport<Output = (PeerId, Muxer)> + Send + Unpin + 'static, R: TryIntoTransport<OtherTransport>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>, R::Error>
Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, OtherTransportPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, OtherTransportPhase<T>>
pub fn with_dns( self, ) -> Result<SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>
async-std
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, OtherTransportPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, OtherTransportPhase<T>>
pub fn with_dns( self, ) -> Result<SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>
tokio
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, OtherTransportPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, OtherTransportPhase<T>>
pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts, ) -> SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>
async-std
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, OtherTransportPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, OtherTransportPhase<T>>
pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts, ) -> SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>
tokio
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport, Provider> SwarmBuilder<Provider, OtherTransportPhase<T>>
impl<T: AuthenticatedMultiplexedTransport, Provider> SwarmBuilder<Provider, OtherTransportPhase<T>>
Sourcepub fn with_relay_client<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Provider, BandwidthLoggingPhase<impl AuthenticatedMultiplexedTransport, Behaviour>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<Connection>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
Available on crate feature relay
only.
pub fn with_relay_client<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Provider, BandwidthLoggingPhase<impl AuthenticatedMultiplexedTransport, Behaviour>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<Connection>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
relay
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>
pub fn with_bandwidth_logging( self, ) -> (SwarmBuilder<Provider, BandwidthMetricsPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>, Arc<BandwidthSinks>)
with_bandwidth_metrics
instead.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>
pub fn with_bandwidth_metrics( self, registry: &mut Registry, ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>
metrics
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
Source§impl SwarmBuilder<NoProviderSpecified, ProviderPhase>
impl SwarmBuilder<NoProviderSpecified, ProviderPhase>
Sourcepub fn with_async_std(self) -> SwarmBuilder<AsyncStd, TcpPhase>
Available on non-WebAssembly and crate feature async-std
only.
pub fn with_async_std(self) -> SwarmBuilder<AsyncStd, TcpPhase>
async-std
only.Configures the SwarmBuilder to use the AsyncStd runtime.
This method is only available when compiling for non-Wasm targets with the async-std
feature enabled.
Sourcepub fn with_tokio(self) -> SwarmBuilder<Tokio, TcpPhase>
Available on non-WebAssembly and crate feature tokio
only.
pub fn with_tokio(self) -> SwarmBuilder<Tokio, TcpPhase>
tokio
only.Configures the SwarmBuilder to use the Tokio runtime.
This method is only available when compiling for non-Wasm targets with the tokio
feature enabled
Sourcepub fn with_wasm_bindgen(self) -> SwarmBuilder<WasmBindgen, TcpPhase>
Available on crate feature wasm-bindgen
only.
pub fn with_wasm_bindgen(self) -> SwarmBuilder<WasmBindgen, TcpPhase>
wasm-bindgen
only.Configures the SwarmBuilder for WebAssembly using WasmBindgen.
This method is available when the wasm-bindgen
feature is enabled.
Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, QuicPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, QuicPhase<T>>
pub fn with_quic( self, ) -> SwarmBuilder<AsyncStd, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>
quic
and crate feature async-std
only.pub fn with_quic_config( self, constructor: impl FnOnce(Config) -> Config, ) -> SwarmBuilder<AsyncStd, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>
quic
and crate feature async-std
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>
pub fn with_quic( self, ) -> SwarmBuilder<Tokio, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>
quic
and crate feature tokio
only.pub fn with_quic_config( self, constructor: impl FnOnce(Config) -> Config, ) -> SwarmBuilder<Tokio, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>
quic
and crate feature tokio
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, QuicPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, QuicPhase<T>>
Sourcepub fn with_relay_client<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Provider, BandwidthLoggingPhase<impl AuthenticatedMultiplexedTransport, Behaviour>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<Connection>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
Available on crate feature relay
only.
pub fn with_relay_client<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Provider, BandwidthLoggingPhase<impl AuthenticatedMultiplexedTransport, Behaviour>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<Connection>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
relay
only.pub fn with_other_transport<Muxer: StreamMuxer + Send + 'static, OtherTransport: Transport<Output = (PeerId, Muxer)> + Send + Unpin + 'static, R: TryIntoTransport<OtherTransport>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>, R::Error>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, QuicPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, QuicPhase<T>>
pub fn with_dns( self, ) -> Result<SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>
async-std
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>
pub fn with_dns( self, ) -> Result<SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>
tokio
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, QuicPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, QuicPhase<T>>
pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts, ) -> SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>
async-std
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>
pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts, ) -> SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>
tokio
and crate feature dns
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, QuicPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, QuicPhase<T>>
Sourcepub async fn with_websocket<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<AsyncStd, RelayPhase<impl AuthenticatedMultiplexedTransport>>, WebsocketError<SecUpgrade::Error>>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
Available on crate feature async-std
and non-WebAssembly and crate feature websocket
only.
pub async fn with_websocket<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<AsyncStd, RelayPhase<impl AuthenticatedMultiplexedTransport>>, WebsocketError<SecUpgrade::Error>>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
async-std
and non-WebAssembly and crate feature websocket
only.Source§impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>
impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>
Sourcepub async fn with_websocket<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Tokio, RelayPhase<impl AuthenticatedMultiplexedTransport>>, WebsocketError<SecUpgrade::Error>>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
Available on crate feature tokio
and non-WebAssembly and crate feature websocket
only.
pub async fn with_websocket<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Tokio, RelayPhase<impl AuthenticatedMultiplexedTransport>>, WebsocketError<SecUpgrade::Error>>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
tokio
and non-WebAssembly and crate feature websocket
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, QuicPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, QuicPhase<T>>
pub fn with_bandwidth_logging( self, ) -> (SwarmBuilder<Provider, BandwidthMetricsPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>, Arc<BandwidthSinks>)
with_bandwidth_metrics
instead.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, QuicPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, QuicPhase<T>>
pub fn with_bandwidth_metrics( self, registry: &mut Registry, ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>
metrics
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, RelayPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, RelayPhase<T>>
Sourcepub fn with_relay_client<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Provider, BandwidthLoggingPhase<impl AuthenticatedMultiplexedTransport, Behaviour>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<Connection>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
Available on crate feature relay
only.
pub fn with_relay_client<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Provider, BandwidthLoggingPhase<impl AuthenticatedMultiplexedTransport, Behaviour>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<Connection>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
relay
only.Adds a relay client transport.
Note that both security_upgrade
and multiplexer_upgrade
take function pointers,
i.e. they take the function themselves (without the invocation via ()
), not the
result of the function invocation. See example below.
let swarm = SwarmBuilder::with_new_identity()
.with_tokio()
.with_tcp(
Default::default(),
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)?
.with_relay_client(
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)?
Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, RelayPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, RelayPhase<T>>
pub fn with_bandwidth_metrics( self, registry: &mut Registry, ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>
metrics
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, RelayPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, RelayPhase<T>>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
Source§impl<T, B> SwarmBuilder<AsyncStd, SwarmPhase<T, B>>
impl<T, B> SwarmBuilder<AsyncStd, SwarmPhase<T, B>>
pub fn with_swarm_config( self, constructor: impl FnOnce(Config) -> Config, ) -> SwarmBuilder<AsyncStd, BuildPhase<T, B>>
async-std
only.pub fn build(self) -> Swarm<B>where
B: NetworkBehaviour,
T: AuthenticatedMultiplexedTransport,
async-std
only.Source§impl<T, B> SwarmBuilder<Tokio, SwarmPhase<T, B>>
impl<T, B> SwarmBuilder<Tokio, SwarmPhase<T, B>>
pub fn with_swarm_config( self, constructor: impl FnOnce(Config) -> Config, ) -> SwarmBuilder<Tokio, BuildPhase<T, B>>
tokio
only.pub fn build(self) -> Swarm<B>where
B: NetworkBehaviour,
T: AuthenticatedMultiplexedTransport,
tokio
only.Source§impl SwarmBuilder<AsyncStd, TcpPhase>
impl SwarmBuilder<AsyncStd, TcpPhase>
Sourcepub fn with_tcp<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
tcp_config: Config,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<AsyncStd, QuicPhase<impl AuthenticatedMultiplexedTransport>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<TcpStream>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<TcpStream>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<TcpStream>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<TcpStream>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<TcpStream>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<TcpStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<TcpStream>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
Available on non-WebAssembly and crate feature tcp
and crate feature async-std
only.
pub fn with_tcp<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
tcp_config: Config,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<AsyncStd, QuicPhase<impl AuthenticatedMultiplexedTransport>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<TcpStream>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<TcpStream>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<TcpStream>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<TcpStream>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<TcpStream>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<TcpStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<TcpStream>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
tcp
and crate feature async-std
only.Adds a TCP based transport.
Note that both security_upgrade
and multiplexer_upgrade
take function pointers,
i.e. they take the function themselves (without the invocation via ()
), not the
result of the function invocation. See example below.
let swarm = SwarmBuilder::with_new_identity()
.with_tokio()
.with_tcp(
Default::default(),
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)?
Source§impl SwarmBuilder<Tokio, TcpPhase>
impl SwarmBuilder<Tokio, TcpPhase>
Sourcepub fn with_tcp<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
tcp_config: Config,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Tokio, QuicPhase<impl AuthenticatedMultiplexedTransport>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<TcpStream>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<TcpStream>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<TcpStream>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<TcpStream>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<TcpStream>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<TcpStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<TcpStream>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
Available on non-WebAssembly and crate feature tcp
and crate feature tokio
only.
pub fn with_tcp<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
tcp_config: Config,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Tokio, QuicPhase<impl AuthenticatedMultiplexedTransport>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<TcpStream>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<TcpStream>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<TcpStream>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<TcpStream>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<TcpStream>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<TcpStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<TcpStream>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
tcp
and crate feature tokio
only.Adds a TCP based transport.
Note that both security_upgrade
and multiplexer_upgrade
take function pointers,
i.e. they take the function themselves (without the invocation via ()
), not the
result of the function invocation. See example below.
let swarm = SwarmBuilder::with_new_identity()
.with_tokio()
.with_tcp(
Default::default(),
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)?
Source§impl SwarmBuilder<AsyncStd, TcpPhase>
impl SwarmBuilder<AsyncStd, TcpPhase>
pub fn with_quic( self, ) -> SwarmBuilder<AsyncStd, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>
quic
and crate feature async-std
only.Source§impl SwarmBuilder<Tokio, TcpPhase>
impl SwarmBuilder<Tokio, TcpPhase>
pub fn with_quic( self, ) -> SwarmBuilder<Tokio, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>
quic
and crate feature tokio
only.Source§impl SwarmBuilder<AsyncStd, TcpPhase>
impl SwarmBuilder<AsyncStd, TcpPhase>
pub fn with_quic_config( self, constructor: impl FnOnce(Config) -> Config, ) -> SwarmBuilder<AsyncStd, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>
quic
and crate feature async-std
only.Source§impl SwarmBuilder<Tokio, TcpPhase>
impl SwarmBuilder<Tokio, TcpPhase>
pub fn with_quic_config( self, constructor: impl FnOnce(Config) -> Config, ) -> SwarmBuilder<Tokio, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>
quic
and crate feature tokio
only.Source§impl<Provider> SwarmBuilder<Provider, TcpPhase>
impl<Provider> SwarmBuilder<Provider, TcpPhase>
pub fn with_other_transport<Muxer: StreamMuxer + Send + 'static, OtherTransport: Transport<Output = (PeerId, Muxer)> + Send + Unpin + 'static, R: TryIntoTransport<OtherTransport>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>, R::Error>
Source§impl SwarmBuilder<AsyncStd, TcpPhase>
impl SwarmBuilder<AsyncStd, TcpPhase>
Sourcepub async fn with_websocket<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<AsyncStd, RelayPhase<impl AuthenticatedMultiplexedTransport>>, WebsocketError<SecUpgrade::Error>>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
Available on crate feature async-std
and non-WebAssembly and crate feature websocket
only.
pub async fn with_websocket<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<AsyncStd, RelayPhase<impl AuthenticatedMultiplexedTransport>>, WebsocketError<SecUpgrade::Error>>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
async-std
and non-WebAssembly and crate feature websocket
only.Source§impl SwarmBuilder<Tokio, TcpPhase>
impl SwarmBuilder<Tokio, TcpPhase>
Sourcepub async fn with_websocket<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Tokio, RelayPhase<impl AuthenticatedMultiplexedTransport>>, WebsocketError<SecUpgrade::Error>>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
Available on crate feature tokio
and non-WebAssembly and crate feature websocket
only.
pub async fn with_websocket<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Tokio, RelayPhase<impl AuthenticatedMultiplexedTransport>>, WebsocketError<SecUpgrade::Error>>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
tokio
and non-WebAssembly and crate feature websocket
only.Source§impl<T> SwarmBuilder<AsyncStd, WebsocketPhase<T>>
impl<T> SwarmBuilder<AsyncStd, WebsocketPhase<T>>
Adds a websocket client transport.
Note that both security_upgrade
and multiplexer_upgrade
take function pointers,
i.e. they take the function themselves (without the invocation via ()
), not the
result of the function invocation. See example below.
let swarm = SwarmBuilder::with_new_identity()
.with_tokio()
.with_websocket(
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)
.await?
pub async fn with_websocket<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<AsyncStd, RelayPhase<impl AuthenticatedMultiplexedTransport>>, WebsocketError<SecUpgrade::Error>>where
T: AuthenticatedMultiplexedTransport,
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
async-std
and crate feature websocket
only.Source§impl<T> SwarmBuilder<Tokio, WebsocketPhase<T>>
impl<T> SwarmBuilder<Tokio, WebsocketPhase<T>>
Adds a websocket client transport.
Note that both security_upgrade
and multiplexer_upgrade
take function pointers,
i.e. they take the function themselves (without the invocation via ()
), not the
result of the function invocation. See example below.
let swarm = SwarmBuilder::with_new_identity()
.with_tokio()
.with_websocket(
(libp2p_tls::Config::new, libp2p_noise::Config::new),
libp2p_yamux::Config::default,
)
.await?
pub async fn with_websocket<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Tokio, RelayPhase<impl AuthenticatedMultiplexedTransport>>, WebsocketError<SecUpgrade::Error>>where
T: AuthenticatedMultiplexedTransport,
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<RwStreamSink<BytesConnection<TcpStream>>>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<RwStreamSink<BytesConnection<TcpStream>>>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
tokio
and crate feature websocket
only.Source§impl<T: AuthenticatedMultiplexedTransport, Provider> SwarmBuilder<Provider, WebsocketPhase<T>>
impl<T: AuthenticatedMultiplexedTransport, Provider> SwarmBuilder<Provider, WebsocketPhase<T>>
Sourcepub fn with_relay_client<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Provider, BandwidthLoggingPhase<impl AuthenticatedMultiplexedTransport, Behaviour>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<Connection>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
Available on crate feature relay
only.
pub fn with_relay_client<SecUpgrade, SecStream, SecError, MuxUpgrade, MuxStream, MuxError>(
self,
security_upgrade: SecUpgrade,
multiplexer_upgrade: MuxUpgrade,
) -> Result<SwarmBuilder<Provider, BandwidthLoggingPhase<impl AuthenticatedMultiplexedTransport, Behaviour>>, SecUpgrade::Error>where
SecStream: AsyncRead + AsyncWrite + Unpin + Send + 'static,
SecError: Error + Send + Sync + 'static,
SecUpgrade: IntoSecurityUpgrade<Connection>,
SecUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + OutboundConnectionUpgrade<Negotiated<Connection>, Output = (PeerId, SecStream), Error = SecError> + Clone + Send + 'static,
<SecUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<SecUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<Connection>>>::Future: Send,
<<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<SecUpgrade as IntoSecurityUpgrade<Connection>>::Upgrade as UpgradeInfo>::Info: Send,
MuxStream: StreamMuxer + Send + 'static,
MuxStream::Substream: Send + 'static,
MuxStream::Error: Send + Sync + 'static,
MuxUpgrade: IntoMultiplexerUpgrade<SecStream>,
MuxUpgrade::Upgrade: InboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + OutboundConnectionUpgrade<Negotiated<SecStream>, Output = MuxStream, Error = MuxError> + Clone + Send + 'static,
<MuxUpgrade::Upgrade as InboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
<MuxUpgrade::Upgrade as OutboundConnectionUpgrade<Negotiated<SecStream>>>::Future: Send,
MuxError: Error + Send + Sync + 'static,
<<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send,
<<MuxUpgrade as IntoMultiplexerUpgrade<SecStream>>::Upgrade as UpgradeInfo>::Info: Send,
relay
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, WebsocketPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, WebsocketPhase<T>>
pub fn with_bandwidth_metrics( self, registry: &mut Registry, ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>
metrics
only.Source§impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, WebsocketPhase<T>>
impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, WebsocketPhase<T>>
pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair) -> R, ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>
Auto Trait Implementations§
impl<Provider, Phase> Freeze for SwarmBuilder<Provider, Phase>where
Phase: Freeze,
impl<Provider, Phase> RefUnwindSafe for SwarmBuilder<Provider, Phase>where
Phase: RefUnwindSafe,
Provider: RefUnwindSafe,
impl<Provider, Phase> Send for SwarmBuilder<Provider, Phase>
impl<Provider, Phase> Sync for SwarmBuilder<Provider, Phase>
impl<Provider, Phase> Unpin for SwarmBuilder<Provider, Phase>
impl<Provider, Phase> UnwindSafe for SwarmBuilder<Provider, Phase>where
Phase: UnwindSafe,
Provider: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more