Struct libp2p::SwarmBuilder

source ·
pub struct SwarmBuilder<Provider, Phase> { /* private fields */ }
Expand description

Build a Swarm by combining an identity, a set of Transports 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>>

source

pub fn with_bandwidth_logging( self ) -> (SwarmBuilder<Provider, BandwidthMetricsPhase<impl AuthenticatedMultiplexedTransport, R>>, Arc<BandwidthSinks>)

👎Deprecated: Use with_bandwidth_metrics instead.
source

pub fn without_bandwidth_logging( self ) -> SwarmBuilder<Provider, BandwidthMetricsPhase<T, R>>

source§

impl<Provider, T: AuthenticatedMultiplexedTransport, R> SwarmBuilder<Provider, BandwidthLoggingPhase<T, R>>

source

pub fn with_bandwidth_metrics( self, registry: &mut Registry ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, R>>

Available on crate feature metrics only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthLoggingPhase<T, Behaviour>>

source

pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair, Behaviour) -> R ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>

Available on crate feature relay only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthLoggingPhase<T, NoRelayBehaviour>>

source

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>>

source

pub fn with_bandwidth_metrics( self, registry: &mut Registry ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, R>>

Available on crate feature metrics only.
source§

impl<T, Provider, R> SwarmBuilder<Provider, BandwidthMetricsPhase<T, R>>

source

pub fn without_bandwidth_metrics( self ) -> SwarmBuilder<Provider, BehaviourPhase<T, R>>

source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthMetricsPhase<T, Behaviour>>

source

pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair, Behaviour) -> R ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>

Available on crate feature relay only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, BandwidthMetricsPhase<T, NoRelayBehaviour>>

source

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>>

source

pub fn with_behaviour<B, R: TryIntoBehaviour<B>>( self, constructor: impl FnOnce(&Keypair, Behaviour) -> R ) -> Result<SwarmBuilder<Provider, SwarmPhase<T, B>>, R::Error>

Available on crate feature relay only.
source§

impl<T, Provider> SwarmBuilder<Provider, BehaviourPhase<T, NoRelayBehaviour>>

source

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>>

source

pub fn build(self) -> Swarm<B>

source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, DnsPhase<T>>

source

pub async fn with_dns( self ) -> Result<SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>

Available on non-WebAssembly and crate feature async-std and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, DnsPhase<T>>

source

pub fn with_dns( self ) -> Result<SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>

Available on non-WebAssembly and crate feature tokio and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, DnsPhase<T>>

source

pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts ) -> SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature async-std and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, DnsPhase<T>>

source

pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts ) -> SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature tokio and crate feature dns only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, DnsPhase<T>>

source

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>

source

pub fn with_new_identity() -> SwarmBuilder<NoProviderSpecified, ProviderPhase>

source

pub fn with_existing_identity( keypair: Keypair ) -> SwarmBuilder<NoProviderSpecified, ProviderPhase>

source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>

source

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>
where <OtherTransport as Transport>::Error: Send + Sync + 'static, <OtherTransport as Transport>::Dial: Send, <OtherTransport as Transport>::ListenerUpgrade: Send, <Muxer as StreamMuxer>::Substream: Send, <Muxer as StreamMuxer>::Error: Send + Sync,

source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, OtherTransportPhase<T>>

source

pub async fn with_dns( self ) -> Result<SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>

Available on non-WebAssembly and crate feature async-std and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, OtherTransportPhase<T>>

source

pub fn with_dns( self ) -> Result<SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>

Available on non-WebAssembly and crate feature tokio and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, OtherTransportPhase<T>>

source

pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts ) -> SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature async-std and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, OtherTransportPhase<T>>

source

pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts ) -> SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature tokio and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport, Provider> SwarmBuilder<Provider, OtherTransportPhase<T>>

source

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,

Available on crate feature relay only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>

source

pub fn with_bandwidth_logging( self ) -> (SwarmBuilder<Provider, BandwidthMetricsPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>, Arc<BandwidthSinks>)

👎Deprecated: Use with_bandwidth_metrics instead.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>

source

pub fn with_bandwidth_metrics( self, registry: &mut Registry ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>

Available on crate feature metrics only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, OtherTransportPhase<T>>

source

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>

source

pub fn with_async_std(self) -> SwarmBuilder<AsyncStd, TcpPhase>

Available on non-WebAssembly and crate feature 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.

source

pub fn with_tokio(self) -> SwarmBuilder<Tokio, TcpPhase>

Available on non-WebAssembly and crate feature 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

source

pub fn with_wasm_bindgen(self) -> SwarmBuilder<WasmBindgen, TcpPhase>

Available on crate feature 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>>

source

pub fn with_quic( self ) -> SwarmBuilder<AsyncStd, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature quic and crate feature async-std only.
source

pub fn with_quic_config( self, constructor: impl FnOnce(Config) -> Config ) -> SwarmBuilder<AsyncStd, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature quic and crate feature async-std only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>

source

pub fn with_quic( self ) -> SwarmBuilder<Tokio, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature quic and crate feature tokio only.
source

pub fn with_quic_config( self, constructor: impl FnOnce(Config) -> Config ) -> SwarmBuilder<Tokio, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature quic and crate feature tokio only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, QuicPhase<T>>

source

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,

Available on crate feature relay only.
source

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>
where <OtherTransport as Transport>::Error: Send + Sync + 'static, <OtherTransport as Transport>::Dial: Send, <OtherTransport as Transport>::ListenerUpgrade: Send, <Muxer as StreamMuxer>::Substream: Send, <Muxer as StreamMuxer>::Error: Send + Sync,

source

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>>

source

pub async fn with_dns( self ) -> Result<SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>

Available on non-WebAssembly and crate feature async-std and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>

source

pub fn with_dns( self ) -> Result<SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>, Error>

Available on non-WebAssembly and crate feature tokio and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, QuicPhase<T>>

source

pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts ) -> SwarmBuilder<AsyncStd, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature async-std and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>

source

pub fn with_dns_config( self, cfg: ResolverConfig, opts: ResolverOpts ) -> SwarmBuilder<Tokio, WebsocketPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature tokio and crate feature dns only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<AsyncStd, QuicPhase<T>>

source

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,

Available on crate feature async-std and non-WebAssembly and crate feature websocket only.
source§

impl<T: AuthenticatedMultiplexedTransport> SwarmBuilder<Tokio, QuicPhase<T>>

source

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,

Available on crate feature tokio and non-WebAssembly and crate feature websocket only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, QuicPhase<T>>

source

pub fn with_bandwidth_logging( self ) -> (SwarmBuilder<Provider, BandwidthMetricsPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>, Arc<BandwidthSinks>)

👎Deprecated: Use with_bandwidth_metrics instead.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, QuicPhase<T>>

source

pub fn with_bandwidth_metrics( self, registry: &mut Registry ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>

Available on crate feature metrics only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, RelayPhase<T>>

source

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,

Available on crate feature 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>>

source

pub fn with_bandwidth_metrics( self, registry: &mut Registry ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>

Available on crate feature metrics only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, RelayPhase<T>>

source

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>>

source

pub fn with_swarm_config( self, constructor: impl FnOnce(Config) -> Config ) -> SwarmBuilder<AsyncStd, BuildPhase<T, B>>

Available on crate feature async-std only.
source

pub fn build(self) -> Swarm<B>
where B: NetworkBehaviour, T: AuthenticatedMultiplexedTransport,

Available on crate feature async-std only.
source§

impl<T, B> SwarmBuilder<Tokio, SwarmPhase<T, B>>

source

pub fn with_swarm_config( self, constructor: impl FnOnce(Config) -> Config ) -> SwarmBuilder<Tokio, BuildPhase<T, B>>

Available on crate feature tokio only.
source

pub fn build(self) -> Swarm<B>
where B: NetworkBehaviour, T: AuthenticatedMultiplexedTransport,

Available on crate feature tokio only.
source§

impl SwarmBuilder<AsyncStd, TcpPhase>

source

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,

Available on non-WebAssembly and crate feature 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>

source

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,

Available on non-WebAssembly and crate feature 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>

source

pub fn with_quic( self ) -> SwarmBuilder<AsyncStd, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature quic and crate feature async-std only.
source§

impl SwarmBuilder<Tokio, TcpPhase>

source

pub fn with_quic( self ) -> SwarmBuilder<Tokio, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature quic and crate feature tokio only.
source§

impl SwarmBuilder<AsyncStd, TcpPhase>

source

pub fn with_quic_config( self, constructor: impl FnOnce(Config) -> Config ) -> SwarmBuilder<AsyncStd, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature quic and crate feature async-std only.
source§

impl SwarmBuilder<Tokio, TcpPhase>

source

pub fn with_quic_config( self, constructor: impl FnOnce(Config) -> Config ) -> SwarmBuilder<Tokio, OtherTransportPhase<impl AuthenticatedMultiplexedTransport>>

Available on non-WebAssembly and crate feature quic and crate feature tokio only.
source§

impl<Provider> SwarmBuilder<Provider, TcpPhase>

source

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>
where <OtherTransport as Transport>::Error: Send + Sync + 'static, <OtherTransport as Transport>::Dial: Send, <OtherTransport as Transport>::ListenerUpgrade: Send, <Muxer as StreamMuxer>::Substream: Send, <Muxer as StreamMuxer>::Error: Send + Sync,

source§

impl SwarmBuilder<AsyncStd, TcpPhase>

source

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,

Available on crate feature async-std and non-WebAssembly and crate feature websocket only.
source§

impl SwarmBuilder<Tokio, TcpPhase>

source

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,

Available on crate feature tokio and non-WebAssembly and crate feature websocket only.
source§

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?
source

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,

Available on non-WebAssembly and crate feature async-std and crate feature websocket only.
source§

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?
source

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,

Available on non-WebAssembly and crate feature tokio and crate feature websocket only.
source§

impl<T: AuthenticatedMultiplexedTransport, Provider> SwarmBuilder<Provider, WebsocketPhase<T>>

source

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,

Available on crate feature relay only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, WebsocketPhase<T>>

source

pub fn with_bandwidth_metrics( self, registry: &mut Registry ) -> SwarmBuilder<Provider, BehaviourPhase<impl AuthenticatedMultiplexedTransport, NoRelayBehaviour>>

Available on crate feature metrics only.
source§

impl<Provider, T: AuthenticatedMultiplexedTransport> SwarmBuilder<Provider, WebsocketPhase<T>>

source

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>
where Phase: Send, Provider: Send,

§

impl<Provider, Phase> Sync for SwarmBuilder<Provider, Phase>
where Phase: Sync, Provider: Sync,

§

impl<Provider, Phase> Unpin for SwarmBuilder<Provider, Phase>
where Phase: Unpin, Provider: Unpin,

§

impl<Provider, Phase> UnwindSafe for SwarmBuilder<Provider, Phase>
where Phase: UnwindSafe, Provider: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more