pub struct NodeMetadata {Show 13 fields
pub node_id: NodeId,
pub name: Option<String>,
pub description: Option<String>,
pub owner: Option<String>,
pub location: Option<LocationInfo>,
pub topology: TopologyHints,
pub status: NodeStatus,
pub custom: HashMap<String, String>,
pub version: u64,
pub updated_at: u64,
pub created_at: u64,
pub tags: HashSet<String>,
pub roles: HashSet<String>,
}Expand description
Complete node metadata
Fields§
§node_id: NodeIdUnique node identifier
name: Option<String>Human-readable node name
description: Option<String>Node description
owner: Option<String>Owner identifier (org, user, etc.)
location: Option<LocationInfo>Geographic location
topology: TopologyHintsTopology hints
status: NodeStatusCurrent status
custom: HashMap<String, String>Custom key-value metadata
version: u64Metadata version (monotonic)
updated_at: u64Last update timestamp (Unix millis)
created_at: u64Creation timestamp (Unix millis)
Tags for categorization
roles: HashSet<String>Node roles
Implementations§
Source§impl NodeMetadata
impl NodeMetadata
Sourcepub fn validate_bounds(&self) -> Result<(), MetadataError>
pub fn validate_bounds(&self) -> Result<(), MetadataError>
Validate that the metadata fits within the per-field boundedness caps (string lengths, tag/role/custom counts, preferred-peers / hop-distances / public-addresses sizes).
Without these caps the deserialize path is unbounded —
every Vec / HashMap / String would accept whatever
the peer shipped, and MetadataStore::upsert would
happily index millions of attacker-supplied tags into the
per-tag inverted-index DashMap. upsert (and
update_versioned) call validate_bounds before touching
the indexes; oversized metadata surfaces as
MetadataError::Invalid(...).
Sourcepub fn with_owner(self, owner: impl Into<String>) -> Self
pub fn with_owner(self, owner: impl Into<String>) -> Self
Set owner
Sourcepub fn with_location(self, location: LocationInfo) -> Self
pub fn with_location(self, location: LocationInfo) -> Self
Set location
Sourcepub fn with_topology(self, topology: TopologyHints) -> Self
pub fn with_topology(self, topology: TopologyHints) -> Self
Set topology
Sourcepub fn with_status(self, status: NodeStatus) -> Self
pub fn with_status(self, status: NodeStatus) -> Self
Set status
Sourcepub fn with_custom(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_custom( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add custom metadata
Sourcepub fn routing_score(&self) -> f64
pub fn routing_score(&self) -> f64
Calculate routing score for this node
Trait Implementations§
Source§impl Clone for NodeMetadata
impl Clone for NodeMetadata
Source§fn clone(&self) -> NodeMetadata
fn clone(&self) -> NodeMetadata
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 NodeMetadata
impl Debug for NodeMetadata
Source§impl<'de> Deserialize<'de> for NodeMetadata
impl<'de> Deserialize<'de> for NodeMetadata
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>,
Source§impl PartialEq for NodeMetadata
impl PartialEq for NodeMetadata
Source§fn eq(&self, other: &NodeMetadata) -> bool
fn eq(&self, other: &NodeMetadata) -> bool
self and other values to be equal, and is used by ==.