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 [u8]) -> &mut Self
pub fn set_protocol_name(&mut self, protocol_name: &'static [u8]) -> &mut Self
Set the protocol name.
use libp2p_mplex::MplexConfig;
let mut muxer_config = MplexConfig::new();
muxer_config.set_protocol_name(b"/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> InboundUpgrade<C> for MplexConfigwhere
C: AsyncRead + AsyncWrite + Unpin,
impl<C> InboundUpgrade<C> for MplexConfigwhere C: AsyncRead + AsyncWrite + Unpin,
source§impl<C> OutboundUpgrade<C> for MplexConfigwhere
C: AsyncRead + AsyncWrite + Unpin,
impl<C> OutboundUpgrade<C> for MplexConfigwhere C: AsyncRead + AsyncWrite + Unpin,
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
.source§fn protocol_info(&self) -> Self::InfoIter
fn protocol_info(&self) -> Self::InfoIter
Auto Trait Implementations§
impl RefUnwindSafe for MplexConfig
impl Send for MplexConfig
impl Sync for MplexConfig
impl Unpin for MplexConfig
impl UnwindSafe for MplexConfig
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<C, U> InboundUpgradeExt<C> for Uwhere
U: InboundUpgrade<C>,
impl<C, U> InboundUpgradeExt<C> for Uwhere U: InboundUpgrade<C>,
source§fn map_inbound<F, T>(self, f: F) -> MapInboundUpgrade<Self, F>where
Self: Sized,
F: FnOnce(Self::Output) -> T,
fn map_inbound<F, T>(self, f: F) -> MapInboundUpgrade<Self, F>where Self: Sized, F: FnOnce(Self::Output) -> T,
Self
and applies a closure to the Output
.source§fn map_inbound_err<F, T>(self, f: F) -> MapInboundUpgradeErr<Self, F>where
Self: Sized,
F: FnOnce(Self::Error) -> T,
fn map_inbound_err<F, T>(self, f: F) -> MapInboundUpgradeErr<Self, F>where Self: Sized, F: FnOnce(Self::Error) -> T,
Self
and applies a closure to the Error
.source§impl<C, U> OutboundUpgradeExt<C> for Uwhere
U: OutboundUpgrade<C>,
impl<C, U> OutboundUpgradeExt<C> for Uwhere U: OutboundUpgrade<C>,
source§fn map_outbound<F, T>(self, f: F) -> MapOutboundUpgrade<Self, F>where
Self: Sized,
F: FnOnce(Self::Output) -> T,
fn map_outbound<F, T>(self, f: F) -> MapOutboundUpgrade<Self, F>where Self: Sized, F: FnOnce(Self::Output) -> T,
Self
and applies a closure to the Output
.source§fn map_outbound_err<F, T>(self, f: F) -> MapOutboundUpgradeErr<Self, F>where
Self: Sized,
F: FnOnce(Self::Error) -> T,
fn map_outbound_err<F, T>(self, f: F) -> MapOutboundUpgradeErr<Self, F>where Self: Sized, F: FnOnce(Self::Error) -> T,
Self
and applies a closure to the Error
.