Struct libp2p::swarm::SubstreamProtocol
source · pub struct SubstreamProtocol<TUpgrade, TInfo> { /* private fields */ }
Expand description
Configuration of inbound or outbound substream protocol(s)
for a ConnectionHandler
.
The inbound substream protocol(s) are defined by ConnectionHandler::listen_protocol
and the outbound substream protocol(s) by ConnectionHandlerEvent::OutboundSubstreamRequest
.
Implementations§
source§impl<TUpgrade, TInfo> SubstreamProtocol<TUpgrade, TInfo>
impl<TUpgrade, TInfo> SubstreamProtocol<TUpgrade, TInfo>
sourcepub fn new(upgrade: TUpgrade, info: TInfo) -> SubstreamProtocol<TUpgrade, TInfo>
pub fn new(upgrade: TUpgrade, info: TInfo) -> SubstreamProtocol<TUpgrade, TInfo>
Create a new SubstreamProtocol
from the given upgrade.
The default timeout for applying the given upgrade on a substream is 10 seconds.
sourcepub fn map_upgrade<U, F>(self, f: F) -> SubstreamProtocol<U, TInfo>where
F: FnOnce(TUpgrade) -> U,
pub fn map_upgrade<U, F>(self, f: F) -> SubstreamProtocol<U, TInfo>where F: FnOnce(TUpgrade) -> U,
Maps a function over the protocol upgrade.
sourcepub fn map_info<U, F>(self, f: F) -> SubstreamProtocol<TUpgrade, U>where
F: FnOnce(TInfo) -> U,
pub fn map_info<U, F>(self, f: F) -> SubstreamProtocol<TUpgrade, U>where F: FnOnce(TInfo) -> U,
Maps a function over the protocol info.
sourcepub fn with_timeout(
self,
timeout: Duration
) -> SubstreamProtocol<TUpgrade, TInfo>
pub fn with_timeout( self, timeout: Duration ) -> SubstreamProtocol<TUpgrade, TInfo>
Sets a new timeout for the protocol upgrade.
sourcepub fn into_upgrade(self) -> (TUpgrade, TInfo)
pub fn into_upgrade(self) -> (TUpgrade, TInfo)
Converts the substream protocol configuration into the contained upgrade.
Trait Implementations§
source§impl<TUpgrade, TInfo> Clone for SubstreamProtocol<TUpgrade, TInfo>where
TUpgrade: Clone,
TInfo: Clone,
impl<TUpgrade, TInfo> Clone for SubstreamProtocol<TUpgrade, TInfo>where TUpgrade: Clone, TInfo: Clone,
source§fn clone(&self) -> SubstreamProtocol<TUpgrade, TInfo>
fn clone(&self) -> SubstreamProtocol<TUpgrade, TInfo>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<TUpgrade, TInfo> Debug for SubstreamProtocol<TUpgrade, TInfo>where
TUpgrade: Debug,
TInfo: Debug,
impl<TUpgrade, TInfo> Debug for SubstreamProtocol<TUpgrade, TInfo>where TUpgrade: Debug, TInfo: Debug,
source§impl<TUpgrade, TInfo> PartialEq<SubstreamProtocol<TUpgrade, TInfo>> for SubstreamProtocol<TUpgrade, TInfo>where
TUpgrade: PartialEq<TUpgrade>,
TInfo: PartialEq<TInfo>,
impl<TUpgrade, TInfo> PartialEq<SubstreamProtocol<TUpgrade, TInfo>> for SubstreamProtocol<TUpgrade, TInfo>where TUpgrade: PartialEq<TUpgrade>, TInfo: PartialEq<TInfo>,
source§fn eq(&self, other: &SubstreamProtocol<TUpgrade, TInfo>) -> bool
fn eq(&self, other: &SubstreamProtocol<TUpgrade, TInfo>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<TUpgrade, TInfo> Copy for SubstreamProtocol<TUpgrade, TInfo>where TUpgrade: Copy, TInfo: Copy,
impl<TUpgrade, TInfo> Eq for SubstreamProtocol<TUpgrade, TInfo>where TUpgrade: Eq, TInfo: Eq,
impl<TUpgrade, TInfo> StructuralEq for SubstreamProtocol<TUpgrade, TInfo>
impl<TUpgrade, TInfo> StructuralPartialEq for SubstreamProtocol<TUpgrade, TInfo>
Auto Trait Implementations§
impl<TUpgrade, TInfo> RefUnwindSafe for SubstreamProtocol<TUpgrade, TInfo>where TInfo: RefUnwindSafe, TUpgrade: RefUnwindSafe,
impl<TUpgrade, TInfo> Send for SubstreamProtocol<TUpgrade, TInfo>where TInfo: Send, TUpgrade: Send,
impl<TUpgrade, TInfo> Sync for SubstreamProtocol<TUpgrade, TInfo>where TInfo: Sync, TUpgrade: Sync,
impl<TUpgrade, TInfo> Unpin for SubstreamProtocol<TUpgrade, TInfo>where TInfo: Unpin, TUpgrade: Unpin,
impl<TUpgrade, TInfo> UnwindSafe for SubstreamProtocol<TUpgrade, TInfo>where TInfo: UnwindSafe, TUpgrade: UnwindSafe,
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
Mutably borrows from an owned value. Read more