pub struct ServiceDiscoveryProtocol { /* private fields */ }Expand description
Service discovery and peer-list protocol.
Attach alongside UdpNeighborDiscovery or [EtherNeighborDiscovery] in
a CompositeDiscovery to enable service record publication/browsing and
demand-driven neighbor queries.
Implementations§
Source§impl ServiceDiscoveryProtocol
impl ServiceDiscoveryProtocol
Sourcepub fn publish(&self, record: ServiceRecord)
pub fn publish(&self, record: ServiceRecord)
Publish a service record.
Records are stored locally and served in response to browse Interests. Call this whenever the set of served prefixes changes.
Sourcepub fn publish_with_ttl(&self, record: ServiceRecord, ttl_ms: u64)
pub fn publish_with_ttl(&self, record: ServiceRecord, ttl_ms: u64)
Publish a service record with a finite TTL.
The record is automatically withdrawn after ttl_ms milliseconds.
Use this for explicitly time-limited runtime announcements where the
caller manages their own renewal (e.g. a short-lived reservation).
For app-lifetime tracking prefer [publish_with_owner]; for permanent
config-based records use [publish].
Sourcepub fn publish_with_owner(&self, record: ServiceRecord, owner_face: FaceId)
pub fn publish_with_owner(&self, record: ServiceRecord, owner_face: FaceId)
Publish a service record owned by a specific local face.
The record is automatically withdrawn when owner_face goes down.
Use this for runtime announcements (e.g. ndn-ctl service announce)
so that the record disappears when the app’s data face closes, without
requiring the app to explicitly call withdraw.
Config-based records (from served_prefixes) should use the permanent
publish instead.
Sourcepub fn local_records(&self) -> Vec<ServiceRecord>
pub fn local_records(&self) -> Vec<ServiceRecord>
Return a snapshot of locally published service records.
Sourcepub fn all_records(&self) -> Vec<ServiceRecord>
pub fn all_records(&self) -> Vec<ServiceRecord>
Return a snapshot of all known service records — both local and records received from remote peers.
Deduplicated: if the same (announced_prefix, node_name) pair appears
in both tables, the local version takes precedence.
Source§impl ServiceDiscoveryProtocol
impl ServiceDiscoveryProtocol
Sourcepub fn new(node_name: Name, config: ServiceDiscoveryConfig) -> Self
pub fn new(node_name: Name, config: ServiceDiscoveryConfig) -> Self
Create a new ServiceDiscoveryProtocol.
node_name: this node’s NDN name.config: service discovery parameters.
Sourcepub fn with_defaults(node_name: Name) -> Self
pub fn with_defaults(node_name: Name) -> Self
Create with the default ServiceDiscoveryConfig.
Trait Implementations§
Source§impl DiscoveryProtocol for ServiceDiscoveryProtocol
impl DiscoveryProtocol for ServiceDiscoveryProtocol
Source§fn protocol_id(&self) -> ProtocolId
fn protocol_id(&self) -> ProtocolId
Source§fn claimed_prefixes(&self) -> &[Name]
fn claimed_prefixes(&self) -> &[Name]
Source§fn on_face_up(&self, _face_id: FaceId, _ctx: &dyn DiscoveryContext)
fn on_face_up(&self, _face_id: FaceId, _ctx: &dyn DiscoveryContext)
FaceTable::insert).Source§fn on_face_down(&self, face_id: FaceId, ctx: &dyn DiscoveryContext)
fn on_face_down(&self, face_id: FaceId, ctx: &dyn DiscoveryContext)
FaceTable::remove).Source§fn on_inbound(
&self,
raw: &Bytes,
incoming_face: FaceId,
_meta: &InboundMeta,
ctx: &dyn DiscoveryContext,
) -> bool
fn on_inbound( &self, raw: &Bytes, incoming_face: FaceId, _meta: &InboundMeta, ctx: &dyn DiscoveryContext, ) -> bool
Source§fn on_tick(&self, now: Instant, ctx: &dyn DiscoveryContext)
fn on_tick(&self, now: Instant, ctx: &dyn DiscoveryContext)
tick_interval. Read moreSource§fn tick_interval(&self) -> Duration
fn tick_interval(&self) -> Duration
on_tick. Read more