pub struct PingTracker { /* private fields */ }Expand description
Tracks pings on a single relay connection.
Only the last ping needs is useful, any previously sent ping is forgotten and ignored.
Implementations§
Source§impl PingTracker
impl PingTracker
Sourcepub fn new(max_timeout: Duration) -> Self
pub fn new(max_timeout: Duration) -> Self
Creates a new ping tracker with the given maximum ping timeout.
Sourcepub fn max_timeout(&self) -> Duration
pub fn max_timeout(&self) -> Duration
Returns the maximum ping timeout.
Sourcepub fn new_ping_with_timeout(&mut self, timeout: Duration) -> [u8; 8]
pub fn new_ping_with_timeout(&mut self, timeout: Duration) -> [u8; 8]
Starts a new ping with a custom timeout.
Sourcepub fn pong_received(&mut self, data: [u8; 8])
pub fn pong_received(&mut self, data: [u8; 8])
Updates the ping tracker with a received pong.
Only the pong of the most recent ping will do anything. There is no harm feeding any pong however.
Sourcepub fn ping_timeout(&self) -> Duration
pub fn ping_timeout(&self) -> Duration
Returns the timeout for the next ping.
Uses 3x the last measured RTT (to account for jitter), falling back to the default timeout if no RTT has been measured yet.
Trait Implementations§
Source§impl Debug for PingTracker
impl Debug for PingTracker
Auto Trait Implementations§
impl Freeze for PingTracker
impl RefUnwindSafe for PingTracker
impl Send for PingTracker
impl Sync for PingTracker
impl Unpin for PingTracker
impl UnwindSafe for PingTracker
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 more