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 MplexConfig
pub fn set_max_num_streams(&mut self, max: usize) -> &mut MplexConfig
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 MplexConfig
pub fn set_max_buffer_size(&mut self, max: usize) -> &mut MplexConfig
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 MplexConfig
pub fn set_max_buffer_behaviour( &mut self, behaviour: MaxBufferBehaviour ) -> &mut MplexConfig
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 MplexConfig
pub fn set_split_send_size(&mut self, size: usize) -> &mut MplexConfig
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 MplexConfig
pub fn set_protocol_name( &mut self, protocol_name: &'static [u8] ) -> &mut MplexConfig
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,
§type Output = Multiplex<C>
type Output = Multiplex<C>
§type Future = Ready<Result<<MplexConfig as InboundUpgrade<C>>::Output, Error>>
type Future = Ready<Result<<MplexConfig as InboundUpgrade<C>>::Output, Error>>
source§fn upgrade_inbound(
self,
socket: C,
_: <MplexConfig as UpgradeInfo>::Info
) -> <MplexConfig as InboundUpgrade<C>>::Future
fn upgrade_inbound( self, socket: C, _: <MplexConfig as UpgradeInfo>::Info ) -> <MplexConfig as InboundUpgrade<C>>::Future
source§impl<C> OutboundUpgrade<C> for MplexConfigwhere
C: AsyncRead + AsyncWrite + Unpin,
impl<C> OutboundUpgrade<C> for MplexConfigwhere C: AsyncRead + AsyncWrite + Unpin,
§type Output = Multiplex<C>
type Output = Multiplex<C>
§type Future = Ready<Result<<MplexConfig as OutboundUpgrade<C>>::Output, Error>>
type Future = Ready<Result<<MplexConfig as OutboundUpgrade<C>>::Output, Error>>
source§fn upgrade_outbound(
self,
socket: C,
_: <MplexConfig as UpgradeInfo>::Info
) -> <MplexConfig as OutboundUpgrade<C>>::Future
fn upgrade_outbound( self, socket: C, _: <MplexConfig as UpgradeInfo>::Info ) -> <MplexConfig as OutboundUpgrade<C>>::Future
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) -> <MplexConfig as UpgradeInfo>::InfoIter
fn protocol_info(&self) -> <MplexConfig as UpgradeInfo>::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<T, TInfo> InboundUpgradeSend for Twhere
T: InboundUpgrade<Negotiated<SubstreamBox>, Info = TInfo> + UpgradeInfoSend<Info = TInfo>,
TInfo: ProtocolName + Clone + Send + 'static,
<T as InboundUpgrade<Negotiated<SubstreamBox>>>::Output: Send + 'static,
<T as InboundUpgrade<Negotiated<SubstreamBox>>>::Error: Send + 'static,
<T as InboundUpgrade<Negotiated<SubstreamBox>>>::Future: Send + 'static,
impl<T, TInfo> InboundUpgradeSend for Twhere T: InboundUpgrade<Negotiated<SubstreamBox>, Info = TInfo> + UpgradeInfoSend<Info = TInfo>, TInfo: ProtocolName + Clone + Send + 'static, <T as InboundUpgrade<Negotiated<SubstreamBox>>>::Output: Send + 'static, <T as InboundUpgrade<Negotiated<SubstreamBox>>>::Error: Send + 'static, <T as InboundUpgrade<Negotiated<SubstreamBox>>>::Future: Send + 'static,
§type Output = <T as InboundUpgrade<Negotiated<SubstreamBox>>>::Output
type Output = <T as InboundUpgrade<Negotiated<SubstreamBox>>>::Output
InboundUpgrade::Output
.§type Error = <T as InboundUpgrade<Negotiated<SubstreamBox>>>::Error
type Error = <T as InboundUpgrade<Negotiated<SubstreamBox>>>::Error
InboundUpgrade::Error
.§type Future = <T as InboundUpgrade<Negotiated<SubstreamBox>>>::Future
type Future = <T as InboundUpgrade<Negotiated<SubstreamBox>>>::Future
InboundUpgrade::Future
.source§fn upgrade_inbound(
self,
socket: Negotiated<SubstreamBox>,
info: TInfo
) -> <T as InboundUpgradeSend>::Future
fn upgrade_inbound( self, socket: Negotiated<SubstreamBox>, info: TInfo ) -> <T as InboundUpgradeSend>::Future
InboundUpgrade::upgrade_inbound
.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<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
.source§impl<T, TInfo> OutboundUpgradeSend for Twhere
T: OutboundUpgrade<Negotiated<SubstreamBox>, Info = TInfo> + UpgradeInfoSend<Info = TInfo>,
TInfo: ProtocolName + Clone + Send + 'static,
<T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Output: Send + 'static,
<T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Error: Send + 'static,
<T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Future: Send + 'static,
impl<T, TInfo> OutboundUpgradeSend for Twhere T: OutboundUpgrade<Negotiated<SubstreamBox>, Info = TInfo> + UpgradeInfoSend<Info = TInfo>, TInfo: ProtocolName + Clone + Send + 'static, <T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Output: Send + 'static, <T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Error: Send + 'static, <T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Future: Send + 'static,
§type Output = <T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Output
type Output = <T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Output
OutboundUpgrade::Output
.§type Error = <T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Error
type Error = <T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Error
OutboundUpgrade::Error
.§type Future = <T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Future
type Future = <T as OutboundUpgrade<Negotiated<SubstreamBox>>>::Future
OutboundUpgrade::Future
.source§fn upgrade_outbound(
self,
socket: Negotiated<SubstreamBox>,
info: TInfo
) -> <T as OutboundUpgradeSend>::Future
fn upgrade_outbound( self, socket: Negotiated<SubstreamBox>, info: TInfo ) -> <T as OutboundUpgradeSend>::Future
OutboundUpgrade::upgrade_outbound
.source§impl<T> UpgradeInfoSend for Twhere
T: UpgradeInfo + Send + 'static,
<T as UpgradeInfo>::Info: Send + 'static,
<<T as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send + 'static,
impl<T> UpgradeInfoSend for Twhere T: UpgradeInfo + Send + 'static, <T as UpgradeInfo>::Info: Send + 'static, <<T as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter: Send + 'static,
§type Info = <T as UpgradeInfo>::Info
type Info = <T as UpgradeInfo>::Info
UpgradeInfo::Info
.§type InfoIter = <<T as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter
type InfoIter = <<T as UpgradeInfo>::InfoIter as IntoIterator>::IntoIter
UpgradeInfo::InfoIter
.source§fn protocol_info(&self) -> <T as UpgradeInfoSend>::InfoIter
fn protocol_info(&self) -> <T as UpgradeInfoSend>::InfoIter
UpgradeInfo::protocol_info
.