Struct libp2p_mplex::MplexConfig
source · pub struct MplexConfig { /* private fields */ }
Expand description
Configuration for the multiplexer.
Implementations§
source§impl MplexConfig
impl MplexConfig
sourcepub fn new() -> MplexConfig
pub fn new() -> MplexConfig
Builds the default configuration.
sourcepub fn set_max_num_streams(&mut self, max: usize) -> &mut Self
pub fn set_max_num_streams(&mut self, max: usize) -> &mut Self
Sets the maximum number of simultaneously used substreams.
A substream is used as long as it has not been dropped,
even if it may already be closed or reset at the protocol
level (in which case it may still have buffered data that
can be read before the StreamMuxer
API signals EOF).
When the limit is reached, opening of outbound substreams
is delayed until another substream is dropped, whereas new
inbound substreams are immediately answered with a Reset
.
If the number of inbound substreams that need to be reset
accumulates too quickly (judged by internal bounds), the
connection is closed with an error due to the misbehaved
remote.
sourcepub fn set_max_buffer_size(&mut self, max: usize) -> &mut Self
pub fn set_max_buffer_size(&mut self, max: usize) -> &mut Self
Sets the maximum number of frames buffered per substream.
A limit is necessary in order to avoid DoS attacks.
sourcepub fn set_max_buffer_behaviour(
&mut self,
behaviour: MaxBufferBehaviour
) -> &mut Self
pub fn set_max_buffer_behaviour( &mut self, behaviour: MaxBufferBehaviour ) -> &mut Self
Sets the behaviour when the maximum buffer size is reached for a substream.
See the documentation of MaxBufferBehaviour
.
sourcepub fn set_split_send_size(&mut self, size: usize) -> &mut Self
pub fn set_split_send_size(&mut self, size: usize) -> &mut Self
Sets the frame size used when sending data. Capped at 1Mbyte as per the Mplex spec.
sourcepub fn set_protocol_name(&mut self, protocol_name: &'static str) -> &mut Self
pub fn set_protocol_name(&mut self, protocol_name: &'static str) -> &mut Self
Set the protocol name.
use libp2p_mplex::MplexConfig;
let mut muxer_config = MplexConfig::new();
muxer_config.set_protocol_name("/mplex/6.7.0");
Trait Implementations§
source§impl Clone for MplexConfig
impl Clone for MplexConfig
source§fn clone(&self) -> MplexConfig
fn clone(&self) -> MplexConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MplexConfig
impl Debug for MplexConfig
source§impl Default for MplexConfig
impl Default for MplexConfig
source§fn default() -> MplexConfig
fn default() -> MplexConfig
source§impl<C> InboundConnectionUpgrade<C> for MplexConfigwhere
C: AsyncRead + AsyncWrite + Unpin,
impl<C> InboundConnectionUpgrade<C> for MplexConfigwhere C: AsyncRead + AsyncWrite + Unpin,
§type Output = Multiplex<C>
type Output = Multiplex<C>
§type Future = Ready<Result<<MplexConfig as InboundConnectionUpgrade<C>>::Output, Error>>
type Future = Ready<Result<<MplexConfig as InboundConnectionUpgrade<C>>::Output, Error>>
source§impl<C> OutboundConnectionUpgrade<C> for MplexConfigwhere
C: AsyncRead + AsyncWrite + Unpin,
impl<C> OutboundConnectionUpgrade<C> for MplexConfigwhere C: AsyncRead + AsyncWrite + Unpin,
§type Output = Multiplex<C>
type Output = Multiplex<C>
§type Future = Ready<Result<<MplexConfig as OutboundConnectionUpgrade<C>>::Output, Error>>
type Future = Ready<Result<<MplexConfig as OutboundConnectionUpgrade<C>>::Output, Error>>
source§impl UpgradeInfo for MplexConfig
impl UpgradeInfo for MplexConfig
§type InfoIter = Once<<MplexConfig as UpgradeInfo>::Info>
type InfoIter = Once<<MplexConfig as UpgradeInfo>::Info>
protocol_info
.