Struct libp2p_core::network::NetworkConfig
source · [−]pub struct NetworkConfig { /* private fields */ }
Expand description
The (optional) configuration for a Network
.
The default configuration specifies no dedicated task executor, no
connection limits, a connection event buffer size of 32, and a
notify_handler
buffer size of 8.
Implementations
sourceimpl NetworkConfig
impl NetworkConfig
sourcepub fn with_executor(self, e: Box<dyn Executor + Send>) -> Self
pub fn with_executor(self, e: Box<dyn Executor + Send>) -> Self
Configures the executor to use for spawning connection background tasks.
sourcepub fn or_else_with_executor<F>(self, f: F) -> Self where
F: FnOnce() -> Option<Box<dyn Executor + Send>>,
pub fn or_else_with_executor<F>(self, f: F) -> Self where
F: FnOnce() -> Option<Box<dyn Executor + Send>>,
Configures the executor to use for spawning connection background tasks, only if no executor has already been configured.
sourcepub fn with_notify_handler_buffer_size(self, n: NonZeroUsize) -> Self
pub fn with_notify_handler_buffer_size(self, n: NonZeroUsize) -> Self
Sets the maximum number of events sent to a connection’s background task that may be buffered, if the task cannot keep up with their consumption and delivery to the connection handler.
When the buffer for a particular connection is full, notify_handler
will no
longer be able to deliver events to the associated ConnectionHandler
,
thus exerting back-pressure on the connection and peer API.
sourcepub fn with_connection_event_buffer_size(self, n: usize) -> Self
pub fn with_connection_event_buffer_size(self, n: usize) -> Self
Sets the maximum number of buffered connection events (beyond a guaranteed buffer of 1 event per connection).
When the buffer is full, the background tasks of all connections will stall. In this way, the consumers of network events exert back-pressure on the network connection I/O.
sourcepub fn with_connection_limits(self, limits: ConnectionLimits) -> Self
pub fn with_connection_limits(self, limits: ConnectionLimits) -> Self
Sets the connection limits to enforce.
Trait Implementations
sourceimpl Default for NetworkConfig
impl Default for NetworkConfig
sourcefn default() -> NetworkConfig
fn default() -> NetworkConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for NetworkConfig
impl Send for NetworkConfig
impl !Sync for NetworkConfig
impl Unpin for NetworkConfig
impl !UnwindSafe for NetworkConfig
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more