pub struct NodeCapabilities {
pub peer_id: String,
pub capabilities: Vec<NodeCapability>,
pub protocol_version: String,
pub announced_at: u64,
pub ttl_secs: u64,
}Expand description
The full node-level capability advertisement sent by a single peer.
Fields§
§peer_id: StringUnique peer identifier (string form of the libp2p PeerId).
capabilities: Vec<NodeCapability>Ordered list of capabilities the peer supports.
protocol_version: StringIPFRS protocol version string, e.g. "0.2.0".
announced_at: u64Unix epoch timestamp in milliseconds at which the advertisement was created / last refreshed.
ttl_secs: u64Time-to-live in seconds after which this record is considered stale.
Implementations§
Source§impl NodeCapabilities
impl NodeCapabilities
Sourcepub const DEFAULT_TTL_SECS: u64 = 300
pub const DEFAULT_TTL_SECS: u64 = 300
Default TTL used when none is provided explicitly.
Sourcepub fn new(
peer_id: &str,
capabilities: Vec<NodeCapability>,
protocol_version: &str,
) -> Self
pub fn new( peer_id: &str, capabilities: Vec<NodeCapability>, protocol_version: &str, ) -> Self
Create a fresh NodeCapabilities record with the current system time.
announced_at is set to the current Unix time in milliseconds.
ttl_secs defaults to Self::DEFAULT_TTL_SECS (300 s).
Sourcepub fn has_capability(&self, name: &str) -> bool
pub fn has_capability(&self, name: &str) -> bool
Returns true if the peer supports the capability identified by name.
Sourcepub fn is_expired(&self, now_ms: u64) -> bool
pub fn is_expired(&self, now_ms: u64) -> bool
Returns true if the record has expired relative to now_ms.
A record is expired when now_ms > announced_at + ttl_secs * 1000.
Sourcepub fn get_capability(&self, name: &str) -> Option<&NodeCapability>
pub fn get_capability(&self, name: &str) -> Option<&NodeCapability>
Returns a reference to the first NodeCapability whose name matches name,
or None if no such capability is present.
Trait Implementations§
Source§impl Clone for NodeCapabilities
impl Clone for NodeCapabilities
Source§fn clone(&self) -> NodeCapabilities
fn clone(&self) -> NodeCapabilities
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NodeCapabilities
impl Debug for NodeCapabilities
Source§impl<'de> Deserialize<'de> for NodeCapabilities
impl<'de> Deserialize<'de> for NodeCapabilities
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for NodeCapabilities
Source§impl PartialEq for NodeCapabilities
impl PartialEq for NodeCapabilities
Source§fn eq(&self, other: &NodeCapabilities) -> bool
fn eq(&self, other: &NodeCapabilities) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for NodeCapabilities
impl Serialize for NodeCapabilities
impl StructuralPartialEq for NodeCapabilities
Auto Trait Implementations§
impl Freeze for NodeCapabilities
impl RefUnwindSafe for NodeCapabilities
impl Send for NodeCapabilities
impl Sync for NodeCapabilities
impl Unpin for NodeCapabilities
impl UnsafeUnpin for NodeCapabilities
impl UnwindSafe for NodeCapabilities
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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 more