Struct libp2p_swarm::Config
source · pub struct Config { /* private fields */ }
Implementations§
source§impl Config
impl Config
sourcepub fn with_executor(executor: impl Executor + Send + 'static) -> Self
pub fn with_executor(executor: impl Executor + Send + 'static) -> Self
Creates a new Config
from the given executor. The Swarm
is obtained via
Swarm::new
.
sourcepub fn with_tokio_executor() -> Self
pub fn with_tokio_executor() -> Self
Builds a new Config
from the given tokio
executor.
sourcepub fn with_notify_handler_buffer_size(self, n: NonZeroUsize) -> Self
pub fn with_notify_handler_buffer_size(self, n: NonZeroUsize) -> Self
Configures the number of events from the NetworkBehaviour
in
destination to the ConnectionHandler
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.
sourcepub fn with_per_connection_event_buffer_size(self, n: usize) -> Self
pub fn with_per_connection_event_buffer_size(self, n: usize) -> Self
Configures the size of the buffer for events sent by a ConnectionHandler
to the
NetworkBehaviour
.
Each connection has its own buffer.
The ideal value depends on the executor used, the CPU speed and the volume of events.
If this value is too low, then the ConnectionHandler
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
.
sourcepub fn with_dial_concurrency_factor(self, factor: NonZeroU8) -> Self
pub fn with_dial_concurrency_factor(self, factor: NonZeroU8) -> Self
Number of addresses concurrently dialed for a single outbound connection attempt.
sourcepub fn with_substream_upgrade_protocol_override(self, v: Version) -> Self
pub fn with_substream_upgrade_protocol_override(self, v: Version) -> Self
Configures an override for the substream upgrade protocol to use.
The subtream upgrade protocol is the multistream-select protocol used for protocol negotiation on substreams. Since a listener supports all existing versions, the choice of upgrade protocol only effects the “dialer”, i.e. the peer opening a substream.
Note: If configured, specific upgrade protocols for individual
SubstreamProtocol
s emitted by theNetworkBehaviour
are ignored.
sourcepub fn with_max_negotiating_inbound_streams(self, v: usize) -> Self
pub fn with_max_negotiating_inbound_streams(self, v: usize) -> Self
The maximum number of inbound streams concurrently negotiating on a connection. New inbound streams exceeding the limit are dropped and thus reset.
Note: This only enforces a limit on the number of concurrently
negotiating inbound streams. The total number of inbound streams on a
connection is the sum of negotiating and negotiated streams. A limit on
the total number of streams can be enforced at the
StreamMuxerBox
level.
sourcepub fn with_idle_connection_timeout(self, timeout: Duration) -> Self
pub fn with_idle_connection_timeout(self, timeout: Duration) -> Self
How long to keep a connection alive once it is idling.
Defaults to 0.
Auto Trait Implementations§
impl Freeze for Config
impl !RefUnwindSafe for Config
impl Send for Config
impl !Sync for Config
impl Unpin for Config
impl !UnwindSafe for Config
Blanket Implementations§
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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