Struct hyparview::TimeToLive [−][src]
pub struct TimeToLive(_);
TTL of a message.
It decreases by one each time the message is forwarded. If the TTL of a message reaches zero, the message will be handled by the node that keeps the message at the time. So, a TTL can be regarded as the hop count of a message.
Methods
impl TimeToLive
[src]
impl TimeToLive
pub fn new(ttl: u8) -> Self
[src]
pub fn new(ttl: u8) -> Self
Makes a new TimeToLive
instance.
pub fn as_u8(self) -> u8
[src]
pub fn as_u8(self) -> u8
Returns the value of the TTL.
pub fn is_expired(self) -> bool
[src]
pub fn is_expired(self) -> bool
Returns true
if the TTL is expired, otherwise false
.
Examples
use hyparview::TimeToLive; let ttl = TimeToLive::new(10); assert!(!ttl.is_expired()); let ttl = TimeToLive::new(0); assert!(ttl.is_expired());
Trait Implementations
impl Debug for TimeToLive
[src]
impl Debug for TimeToLive
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for TimeToLive
[src]
impl Clone for TimeToLive
fn clone(&self) -> TimeToLive
[src]
fn clone(&self) -> TimeToLive
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for TimeToLive
[src]
impl Copy for TimeToLive
impl PartialEq for TimeToLive
[src]
impl PartialEq for TimeToLive
fn eq(&self, other: &TimeToLive) -> bool
[src]
fn eq(&self, other: &TimeToLive) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &TimeToLive) -> bool
[src]
fn ne(&self, other: &TimeToLive) -> bool
This method tests for !=
.
impl Eq for TimeToLive
[src]
impl Eq for TimeToLive
impl Hash for TimeToLive
[src]
impl Hash for TimeToLive
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialOrd for TimeToLive
[src]
impl PartialOrd for TimeToLive
fn partial_cmp(&self, other: &TimeToLive) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &TimeToLive) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &TimeToLive) -> bool
[src]
fn lt(&self, other: &TimeToLive) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &TimeToLive) -> bool
[src]
fn le(&self, other: &TimeToLive) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &TimeToLive) -> bool
[src]
fn gt(&self, other: &TimeToLive) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &TimeToLive) -> bool
[src]
fn ge(&self, other: &TimeToLive) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for TimeToLive
[src]
impl Ord for TimeToLive
fn cmp(&self, other: &TimeToLive) -> Ordering
[src]
fn cmp(&self, other: &TimeToLive) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
Auto Trait Implementations
impl Send for TimeToLive
impl Send for TimeToLive
impl Sync for TimeToLive
impl Sync for TimeToLive