Struct libp2p::mplex::MplexConfig
source · [−]pub struct MplexConfig { /* private fields */ }
Expand description
Configuration for the multiplexer.
Implementations
sourceimpl 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.
Trait Implementations
sourceimpl Clone for MplexConfig
impl Clone for MplexConfig
sourcepub fn clone(&self) -> MplexConfig
pub fn clone(&self) -> MplexConfig
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for MplexConfig
impl Debug for MplexConfig
sourceimpl Default for MplexConfig
impl Default for MplexConfig
sourcepub fn default() -> MplexConfig
pub fn default() -> MplexConfig
Returns the “default value” for a type. Read more
sourceimpl<C> InboundUpgrade<C> for MplexConfig where
C: AsyncRead + AsyncWrite + Unpin,
impl<C> InboundUpgrade<C> for MplexConfig where
C: AsyncRead + AsyncWrite + Unpin,
type Output = Multiplex<C>
type Output = Multiplex<C>
Output after the upgrade has been successfully negotiated and the handshake performed.
type Future = Ready<Result<<MplexConfig as InboundUpgrade<C>>::Output, Error>>
type Future = Ready<Result<<MplexConfig as InboundUpgrade<C>>::Output, Error>>
Future that performs the handshake with the remote.
sourcepub fn upgrade_inbound(
self,
socket: C,
<MplexConfig as UpgradeInfo>::Info
) -> <MplexConfig as InboundUpgrade<C>>::Future
pub fn upgrade_inbound(
self,
socket: C,
<MplexConfig as UpgradeInfo>::Info
) -> <MplexConfig as InboundUpgrade<C>>::Future
After we have determined that the remote supports one of the protocols we support, this method is called to start the handshake. Read more
sourceimpl<C> OutboundUpgrade<C> for MplexConfig where
C: AsyncRead + AsyncWrite + Unpin,
impl<C> OutboundUpgrade<C> for MplexConfig where
C: AsyncRead + AsyncWrite + Unpin,
type Output = Multiplex<C>
type Output = Multiplex<C>
Output after the upgrade has been successfully negotiated and the handshake performed.
type Future = Ready<Result<<MplexConfig as OutboundUpgrade<C>>::Output, Error>>
type Future = Ready<Result<<MplexConfig as OutboundUpgrade<C>>::Output, Error>>
Future that performs the handshake with the remote.
sourcepub fn upgrade_outbound(
self,
socket: C,
<MplexConfig as UpgradeInfo>::Info
) -> <MplexConfig as OutboundUpgrade<C>>::Future
pub fn upgrade_outbound(
self,
socket: C,
<MplexConfig as UpgradeInfo>::Info
) -> <MplexConfig as OutboundUpgrade<C>>::Future
After we have determined that the remote supports one of the protocols we support, this method is called to start the handshake. Read more
sourceimpl UpgradeInfo for MplexConfig
impl UpgradeInfo for MplexConfig
type Info = &'static [u8]
type Info = &'static [u8]
Opaque type representing a negotiable protocol.
type InfoIter = Once<<MplexConfig as UpgradeInfo>::Info>
type InfoIter = Once<<MplexConfig as UpgradeInfo>::Info>
Iterator returned by protocol_info
.
sourcepub fn protocol_info(&self) -> <MplexConfig as UpgradeInfo>::InfoIter
pub fn protocol_info(&self) -> <MplexConfig as UpgradeInfo>::InfoIter
Returns the list of protocols that are supported. Used during the negotiation process.
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
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
sourceimpl<C, U> InboundUpgradeExt<C> for U where
U: InboundUpgrade<C>,
impl<C, U> InboundUpgradeExt<C> for U where
U: InboundUpgrade<C>,
sourcefn map_inbound<F, T>(self, f: F) -> MapInboundUpgrade<Self, F> where
F: FnOnce(Self::Output) -> T,
fn map_inbound<F, T>(self, f: F) -> MapInboundUpgrade<Self, F> where
F: FnOnce(Self::Output) -> T,
Returns a new object that wraps around Self
and applies a closure to the Output
.
sourcefn map_inbound_err<F, T>(self, f: F) -> MapInboundUpgradeErr<Self, F> where
F: FnOnce(Self::Error) -> T,
fn map_inbound_err<F, T>(self, f: F) -> MapInboundUpgradeErr<Self, F> where
F: FnOnce(Self::Error) -> T,
Returns a new object that wraps around Self
and applies a closure to the Error
.
sourceimpl<C, U> OutboundUpgradeExt<C> for U where
U: OutboundUpgrade<C>,
impl<C, U> OutboundUpgradeExt<C> for U where
U: OutboundUpgrade<C>,
sourcefn map_outbound<F, T>(self, f: F) -> MapOutboundUpgrade<Self, F> where
F: FnOnce(Self::Output) -> T,
fn map_outbound<F, T>(self, f: F) -> MapOutboundUpgrade<Self, F> where
F: FnOnce(Self::Output) -> T,
Returns a new object that wraps around Self
and applies a closure to the Output
.
sourcefn map_outbound_err<F, T>(self, f: F) -> MapOutboundUpgradeErr<Self, F> where
F: FnOnce(Self::Error) -> T,
fn map_outbound_err<F, T>(self, f: F) -> MapOutboundUpgradeErr<Self, F> where
F: FnOnce(Self::Error) -> T,
Returns a new object that wraps around Self
and applies a closure to the Error
.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more