Struct libp2p::swarm::SwarmBuilder [−][src]
A SwarmBuilder
provides an API for configuring and constructing a Swarm
,
including the underlying Network
.
Implementations
impl<TBehaviour, TConnInfo> SwarmBuilder<TBehaviour, TConnInfo> where
TBehaviour: NetworkBehaviour,
TConnInfo: ConnectionInfo<PeerId = PeerId> + Debug + Clone + Send + 'static,
[src]
TBehaviour: NetworkBehaviour,
TConnInfo: ConnectionInfo<PeerId = PeerId> + Debug + Clone + Send + 'static,
pub fn new<TTrans, TMuxer>(
transport: TTrans,
behaviour: TBehaviour,
local_peer_id: PeerId
) -> SwarmBuilder<TBehaviour, TConnInfo> where
TTrans: Transport<Output = (TConnInfo, TMuxer)> + Clone + Send + Sync + 'static,
TMuxer: StreamMuxer + Send + Sync + 'static,
<TMuxer as StreamMuxer>::OutboundSubstream: Send,
<TMuxer as StreamMuxer>::OutboundSubstream: 'static,
<TMuxer as StreamMuxer>::OutboundSubstream: Send,
<TMuxer as StreamMuxer>::OutboundSubstream: 'static,
<TMuxer as StreamMuxer>::Substream: Send,
<TMuxer as StreamMuxer>::Substream: 'static,
<TTrans as Transport>::Error: Send,
<TTrans as Transport>::Error: Sync,
<TTrans as Transport>::Error: 'static,
<TTrans as Transport>::Listener: Send,
<TTrans as Transport>::Listener: 'static,
<TTrans as Transport>::ListenerUpgrade: Send,
<TTrans as Transport>::ListenerUpgrade: 'static,
<TTrans as Transport>::Dial: Send,
<TTrans as Transport>::Dial: 'static,
[src]
transport: TTrans,
behaviour: TBehaviour,
local_peer_id: PeerId
) -> SwarmBuilder<TBehaviour, TConnInfo> where
TTrans: Transport<Output = (TConnInfo, TMuxer)> + Clone + Send + Sync + 'static,
TMuxer: StreamMuxer + Send + Sync + 'static,
<TMuxer as StreamMuxer>::OutboundSubstream: Send,
<TMuxer as StreamMuxer>::OutboundSubstream: 'static,
<TMuxer as StreamMuxer>::OutboundSubstream: Send,
<TMuxer as StreamMuxer>::OutboundSubstream: 'static,
<TMuxer as StreamMuxer>::Substream: Send,
<TMuxer as StreamMuxer>::Substream: 'static,
<TTrans as Transport>::Error: Send,
<TTrans as Transport>::Error: Sync,
<TTrans as Transport>::Error: 'static,
<TTrans as Transport>::Listener: Send,
<TTrans as Transport>::Listener: 'static,
<TTrans as Transport>::ListenerUpgrade: Send,
<TTrans as Transport>::ListenerUpgrade: 'static,
<TTrans as Transport>::Dial: Send,
<TTrans as Transport>::Dial: 'static,
Creates a new SwarmBuilder
from the given transport, behaviour and
local peer ID. The Swarm
with its underlying Network
is obtained
via SwarmBuilder::build
.
pub fn executor(
self,
e: Box<dyn Executor + 'static + Send, Global>
) -> SwarmBuilder<TBehaviour, TConnInfo>
[src]
self,
e: Box<dyn Executor + 'static + Send, Global>
) -> SwarmBuilder<TBehaviour, TConnInfo>
Configures the Executor
to use for spawning background tasks.
By default, unless another executor has been configured,
SwarmBuilder::build
will try to set up a ThreadPool
.
pub fn notify_handler_buffer_size(
self,
n: NonZeroUsize
) -> SwarmBuilder<TBehaviour, TConnInfo>
[src]
self,
n: NonZeroUsize
) -> SwarmBuilder<TBehaviour, TConnInfo>
Configures the number of events from the NetworkBehaviour
in
destination to the ProtocolsHandler
that can be buffered before
the Swarm
has to wait. An individual buffer with this number of
events exists for each individual connection.
The ideal value depends on the executor used, the CPU speed, and the
volume of events. If this value is too low, then the Swarm
will
be sleeping more often than necessary. Increasing this value increases
the overall memory usage.
pub fn connection_event_buffer_size(
self,
n: usize
) -> SwarmBuilder<TBehaviour, TConnInfo>
[src]
self,
n: usize
) -> SwarmBuilder<TBehaviour, TConnInfo>
Configures the number of extra events from the ProtocolsHandler
in
destination to the NetworkBehaviour
that can be buffered before
the ProtocolsHandler
has to go to sleep.
There exists a buffer of events received from ProtocolsHandler
s
that the NetworkBehaviour
has yet to process. This buffer is
shared between all instances of ProtocolsHandler
. Each instance of
ProtocolsHandler
is guaranteed one slot in this buffer, meaning
that delivering an event for the first time is guaranteed to be
instantaneous. Any extra event delivery, however, must wait for that
first event to be delivered or for an “extra slot” to be available.
This option configures the number of such “extra slots” in this shared buffer. These extra slots are assigned in a first-come, first-served basis.
The ideal value depends on the executor used, the CPU speed, the
average number of connections, and the volume of events. If this value
is too low, then the ProtocolsHandler
s will be sleeping more often
than necessary. Increasing this value increases the overall memory
usage, and more importantly the latency between the moment when an
event is emitted and the moment when it is received by the
NetworkBehaviour
.
pub fn incoming_connection_limit(
self,
n: usize
) -> SwarmBuilder<TBehaviour, TConnInfo>
[src]
self,
n: usize
) -> SwarmBuilder<TBehaviour, TConnInfo>
Configures a limit for the number of simultaneous incoming connection attempts.
pub fn outgoing_connection_limit(
self,
n: usize
) -> SwarmBuilder<TBehaviour, TConnInfo>
[src]
self,
n: usize
) -> SwarmBuilder<TBehaviour, TConnInfo>
Configures a limit for the number of simultaneous outgoing connection attempts.
pub fn peer_connection_limit(
self,
n: usize
) -> SwarmBuilder<TBehaviour, TConnInfo>
[src]
self,
n: usize
) -> SwarmBuilder<TBehaviour, TConnInfo>
Configures a limit for the number of simultaneous established connections per peer.
pub fn build(
self
) -> ExpandedSwarm<TBehaviour, <<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent, <<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutEvent, <TBehaviour as NetworkBehaviour>::ProtocolsHandler, TConnInfo>
[src]
self
) -> ExpandedSwarm<TBehaviour, <<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent, <<<TBehaviour as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutEvent, <TBehaviour as NetworkBehaviour>::ProtocolsHandler, TConnInfo>
Builds a Swarm
with the current configuration.
Auto Trait Implementations
impl<TBehaviour, TConnInfo> !RefUnwindSafe for SwarmBuilder<TBehaviour, TConnInfo>
impl<TBehaviour, TConnInfo> Send for SwarmBuilder<TBehaviour, TConnInfo> where
TBehaviour: Send,
TBehaviour: Send,
impl<TBehaviour, TConnInfo> !Sync for SwarmBuilder<TBehaviour, TConnInfo>
impl<TBehaviour, TConnInfo> Unpin for SwarmBuilder<TBehaviour, TConnInfo> where
TBehaviour: Unpin,
TBehaviour: Unpin,
impl<TBehaviour, TConnInfo> !UnwindSafe for SwarmBuilder<TBehaviour, TConnInfo>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,