pub struct Ping;Expand description
The Ping protocol upgrade.
The ping protocol sends 32 bytes of random data in configurable intervals over a single outbound substream, expecting to receive the same bytes as a response. At the same time, incoming pings on inbound substreams are answered by sending back the received bytes.
At most a single inbound and outbound substream is kept open at any time. In case of a ping timeout or another error on a substream, the substream is dropped. If a configurable number of consecutive outbound pings fail, the connection is closed.
Successful pings report the round-trip time.
Note: The round-trip time of a ping may be subject to delays induced by the underlying transport, e.g. in the case of TCP there is Nagle’s algorithm, delayed acks and similar configuration options which can affect latencies especially on otherwise low-volume connections.
Trait Implementations§
Source§impl InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>> for Ping
impl InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>> for Ping
Source§type Output = Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>
type Output = Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>
Source§type Future = Ready<Result<<Ping as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output, <Ping as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error>>
type Future = Ready<Result<<Ping as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output, <Ping as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error>>
Source§fn upgrade_inbound(
self,
stream: NegotiatedSubstream,
_: Self::Info,
) -> Self::Future
fn upgrade_inbound( self, stream: NegotiatedSubstream, _: Self::Info, ) -> Self::Future
Source§impl OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>> for Ping
impl OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>> for Ping
Source§type Output = Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>
type Output = Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>
Source§type Future = Ready<Result<<Ping as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output, <Ping as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error>>
type Future = Ready<Result<<Ping as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output, <Ping as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error>>
Source§fn upgrade_outbound(
self,
stream: NegotiatedSubstream,
_: Self::Info,
) -> Self::Future
fn upgrade_outbound( self, stream: NegotiatedSubstream, _: Self::Info, ) -> Self::Future
Source§impl UpgradeInfo for Ping
impl UpgradeInfo for Ping
Source§fn protocol_info(&self) -> Self::InfoIter
fn protocol_info(&self) -> Self::InfoIter
impl Copy for Ping
Auto Trait Implementations§
impl Freeze for Ping
impl RefUnwindSafe for Ping
impl Send for Ping
impl Sync for Ping
impl Unpin for Ping
impl UnwindSafe for Ping
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
fn map_inbound<F, T>(self, f: F) -> MapInboundUpgrade<Self, F>
Self and applies a closure to the Output.Source§fn map_inbound_err<F, T>(self, f: F) -> MapInboundUpgradeErr<Self, F>
fn map_inbound_err<F, T>(self, f: F) -> MapInboundUpgradeErr<Self, F>
Self and applies a closure to the Error.Source§impl<T, TInfo> InboundUpgradeSend for Twhere
T: InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>, Info = TInfo> + UpgradeInfoSend<Info = TInfo>,
TInfo: ProtocolName + Clone + Send + 'static,
<T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output: Send + 'static,
<T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error: Send + 'static,
<T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Future: Send + 'static,
impl<T, TInfo> InboundUpgradeSend for Twhere
T: InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>, Info = TInfo> + UpgradeInfoSend<Info = TInfo>,
TInfo: ProtocolName + Clone + Send + 'static,
<T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output: Send + 'static,
<T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error: Send + 'static,
<T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Future: Send + 'static,
Source§type Output = <T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output
type Output = <T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output
InboundUpgrade::Output.Source§type Error = <T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error
type Error = <T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error
InboundUpgrade::Error.Source§type Future = <T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Future
type Future = <T as InboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Future
InboundUpgrade::Future.Source§fn upgrade_inbound(
self,
socket: Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>,
info: TInfo,
) -> <T as InboundUpgradeSend>::Future
fn upgrade_inbound( self, socket: Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>, info: TInfo, ) -> <T as InboundUpgradeSend>::Future
InboundUpgrade::upgrade_inbound.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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>
fn map_outbound<F, T>(self, f: F) -> MapOutboundUpgrade<Self, F>
Self and applies a closure to the Output.Source§fn map_outbound_err<F, T>(self, f: F) -> MapOutboundUpgradeErr<Self, F>
fn map_outbound_err<F, T>(self, f: F) -> MapOutboundUpgradeErr<Self, F>
Self and applies a closure to the Error.Source§impl<T, TInfo> OutboundUpgradeSend for Twhere
T: OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>, Info = TInfo> + UpgradeInfoSend<Info = TInfo>,
TInfo: ProtocolName + Clone + Send + 'static,
<T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output: Send + 'static,
<T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error: Send + 'static,
<T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Future: Send + 'static,
impl<T, TInfo> OutboundUpgradeSend for Twhere
T: OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>, Info = TInfo> + UpgradeInfoSend<Info = TInfo>,
TInfo: ProtocolName + Clone + Send + 'static,
<T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output: Send + 'static,
<T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error: Send + 'static,
<T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Future: Send + 'static,
Source§type Output = <T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output
type Output = <T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Output
OutboundUpgrade::Output.Source§type Error = <T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error
type Error = <T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Error
OutboundUpgrade::Error.Source§type Future = <T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Future
type Future = <T as OutboundUpgrade<Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>>>::Future
OutboundUpgrade::Future.Source§fn upgrade_outbound(
self,
socket: Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>,
info: TInfo,
) -> <T as OutboundUpgradeSend>::Future
fn upgrade_outbound( self, socket: Negotiated<SubstreamRef<Arc<StreamMuxerBox>>>, 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,
Source§type Info = <T as UpgradeInfo>::Info
type Info = <T as UpgradeInfo>::Info
UpgradeInfo::Info.Source§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.