Struct libp2p_swarm::protocols_handler::SubstreamProtocol
source · [−]pub struct SubstreamProtocol<TUpgrade, TInfo> { /* private fields */ }
Expand description
Configuration of inbound or outbound substream protocol(s)
for a ProtocolsHandler
.
The inbound substream protocol(s) are defined by ProtocolsHandler::listen_protocol
and the outbound substream protocol(s) by ProtocolsHandlerEvent::OutboundSubstreamRequest
.
Implementations
sourceimpl<TUpgrade, TInfo> SubstreamProtocol<TUpgrade, TInfo>
impl<TUpgrade, TInfo> SubstreamProtocol<TUpgrade, TInfo>
sourcepub fn new(upgrade: TUpgrade, info: TInfo) -> Self
pub fn new(upgrade: TUpgrade, info: TInfo) -> Self
Create a new SubstreamProtocol
from the given upgrade.
The default timeout for applying the given upgrade on a substream is 10 seconds.
sourcepub fn with_upgrade_protocol(self, version: Version) -> Self
pub fn with_upgrade_protocol(self, version: Version) -> Self
Sets the multistream-select protocol (version) to use for negotiating protocols upgrades on outbound substreams.
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) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets a new timeout for the protocol upgrade.
sourcepub fn into_upgrade(self) -> (Version, TUpgrade, TInfo)
pub fn into_upgrade(self) -> (Version, TUpgrade, TInfo)
Converts the substream protocol configuration into the contained upgrade.
Trait Implementations
sourceimpl<TUpgrade: Clone, TInfo: Clone> Clone for SubstreamProtocol<TUpgrade, TInfo>
impl<TUpgrade: Clone, TInfo: Clone> Clone for SubstreamProtocol<TUpgrade, TInfo>
sourcefn clone(&self) -> SubstreamProtocol<TUpgrade, TInfo>
fn clone(&self) -> SubstreamProtocol<TUpgrade, TInfo>
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<TUpgrade: Debug, TInfo: Debug> Debug for SubstreamProtocol<TUpgrade, TInfo>
impl<TUpgrade: Debug, TInfo: Debug> Debug for SubstreamProtocol<TUpgrade, TInfo>
sourceimpl<TUpgrade: PartialEq, TInfo: PartialEq> PartialEq<SubstreamProtocol<TUpgrade, TInfo>> for SubstreamProtocol<TUpgrade, TInfo>
impl<TUpgrade: PartialEq, TInfo: PartialEq> PartialEq<SubstreamProtocol<TUpgrade, TInfo>> for SubstreamProtocol<TUpgrade, TInfo>
sourcefn 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 ==
. Read more
sourcefn ne(&self, other: &SubstreamProtocol<TUpgrade, TInfo>) -> bool
fn ne(&self, other: &SubstreamProtocol<TUpgrade, TInfo>) -> bool
This method tests for !=
.
impl<TUpgrade: Copy, TInfo: Copy> Copy for SubstreamProtocol<TUpgrade, TInfo>
impl<TUpgrade: Eq, TInfo: Eq> Eq for SubstreamProtocol<TUpgrade, TInfo>
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
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<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