pub struct MdnsService { /* private fields */ }Expand description
Long-running mDNS service with discovery, caching, and service registration.
Implementations§
Source§impl MdnsService
impl MdnsService
Sourcepub async fn new() -> Result<Arc<Self>>
pub async fn new() -> Result<Arc<Self>>
Create a new mDNS service.
Call subscribe on the returned handle to receive discovery events.
Multiple independent subscribers may receive events concurrently.
Sourcepub fn subscribe(&self) -> Receiver<MdnsEvent>
pub fn subscribe(&self) -> Receiver<MdnsEvent>
Subscribe to discovery events.
Returns an independent [broadcast::Receiver]; each subscriber receives every event.
Subscribe before calling active_lookup to avoid missing
responses that arrive before the next recv() call.
On lag (RecvError::Lagged), log a warning and keep draining — events are recoverable
by re-issuing active_lookup.
Sourcepub async fn add_query(&self, label: &str, qtype: u16, interval: Duration)
pub async fn add_query(&self, label: &str, qtype: u16, interval: Duration)
Add a periodic query. The query will be sent immediately, then every interval.
Sourcepub async fn remove_query(&self, label: &str)
pub async fn remove_query(&self, label: &str)
Remove a periodic query by label.
Sourcepub async fn register_service(&self, reg: ServiceRegistration)
pub async fn register_service(&self, reg: ServiceRegistration)
Register a local service to be advertised.
Sourcepub async fn unregister_service(&self, instance: &str, service_type: &str)
pub async fn unregister_service(&self, instance: &str, service_type: &str)
Unregister a local service. Sends a goodbye (TTL=0) for the service records.
Sourcepub async fn lookup(&self, name: &str, qtype: u16) -> Vec<RR>
pub async fn lookup(&self, name: &str, qtype: u16) -> Vec<RR>
Lookup cached records by name and type.