Struct libp2p_ping::handler::PingConfig
source · [−]pub struct PingConfig { /* private fields */ }
Expand description
The configuration for outbound pings.
Implementations
sourceimpl PingConfig
impl PingConfig
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new PingConfig
with the following default settings:
PingConfig::with_interval
15sPingConfig::with_timeout
20sPingConfig::with_max_failures
1PingConfig::with_keep_alive
false
These settings have the following effect:
- A ping is sent every 15 seconds on a healthy connection.
- Every ping sent must yield a response within 20 seconds in order to be successful.
- A single ping failure is sufficient for the connection to be subject to being closed.
- The connection may be closed at any time as far as the ping protocol is concerned, i.e. the ping protocol itself does not keep the connection alive.
sourcepub fn with_timeout(self, d: Duration) -> Self
pub fn with_timeout(self, d: Duration) -> Self
Sets the ping timeout.
sourcepub fn with_interval(self, d: Duration) -> Self
pub fn with_interval(self, d: Duration) -> Self
Sets the ping interval.
sourcepub fn with_max_failures(self, n: NonZeroU32) -> Self
pub fn with_max_failures(self, n: NonZeroU32) -> Self
Sets the maximum number of consecutive ping failures upon which the remote peer is considered unreachable and the connection closed.
sourcepub fn with_keep_alive(self, b: bool) -> Self
pub fn with_keep_alive(self, b: bool) -> Self
Sets whether the ping protocol itself should keep the connection alive, apart from the maximum allowed failures.
By default, the ping protocol itself allows the connection to be closed at any time, i.e. in the absence of ping failures the connection lifetime is determined by other protocol handlers.
If the maximum number of allowed ping failures is reached, the
connection is always terminated as a result of ProtocolsHandler::poll
returning an error, regardless of the keep-alive setting.
Trait Implementations
sourceimpl Clone for PingConfig
impl Clone for PingConfig
sourcefn clone(&self) -> PingConfig
fn clone(&self) -> PingConfig
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
Auto Trait Implementations
impl RefUnwindSafe for PingConfig
impl Send for PingConfig
impl Sync for PingConfig
impl Unpin for PingConfig
impl UnwindSafe for PingConfig
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