pub struct ServiceRecord {
pub announced_prefix: Name,
pub node_name: Name,
pub freshness_ms: u64,
pub capabilities: u8,
}Expand description
A service advertisement record.
Produced by a prefix producer to announce its prefix to neighbouring nodes. Consumed by any node doing prefix browsability.
Fields§
§announced_prefix: NameThe prefix being announced (e.g. /ndn/sensor/temp).
node_name: NameThe producer’s NDN node name.
freshness_ms: u64How long (ms) this record should be considered fresh. 0 = rely on
NDN FreshnessPeriod only.
capabilities: u8Capability flags (same encoding as HelloPayload capabilities).
Implementations§
Source§impl ServiceRecord
impl ServiceRecord
Sourcepub fn new(announced_prefix: Name, node_name: Name) -> Self
pub fn new(announced_prefix: Name, node_name: Name) -> Self
Create a minimal record with default freshness (30 s) and no flags.
Sourcepub fn make_name(&self, timestamp_ms: u64) -> Name
pub fn make_name(&self, timestamp_ms: u64) -> Name
Construct the NDN name for this record.
timestamp_ms should be a monotonically increasing value (e.g.
milliseconds since Unix epoch) so that CanBePrefix=true Interests
retrieve the freshest record.
Sourcepub fn build_data(&self, timestamp_ms: u64) -> Bytes
pub fn build_data(&self, timestamp_ms: u64) -> Bytes
Build a complete NDN Data packet for this record.
The Data name follows the naming convention above; the Content is the
encoded ServiceRecord. FreshnessPeriod is set to freshness_ms.
Sourcepub fn from_data_packet(raw: &Bytes) -> Option<Self>
pub fn from_data_packet(raw: &Bytes) -> Option<Self>
Extract and decode the ServiceRecord from a raw NDN Data packet.
Returns None if the packet is not a service record Data or the content
cannot be decoded.
Trait Implementations§
Source§impl Clone for ServiceRecord
impl Clone for ServiceRecord
Source§fn clone(&self) -> ServiceRecord
fn clone(&self) -> ServiceRecord
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more