Skip to main content

MdnsService

Struct MdnsService 

Source
pub struct MdnsService { /* private fields */ }
Expand description

Long-running mDNS service with discovery, caching, and service registration.

Implementations§

Source§

impl MdnsService

Source

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.

Source

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.

Source

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.

Source

pub async fn remove_query(&self, label: &str)

Remove a periodic query by label.

Source

pub async fn register_service(&self, reg: ServiceRegistration)

Register a local service to be advertised.

Source

pub async fn unregister_service(&self, instance: &str, service_type: &str)

Unregister a local service. Sends a goodbye (TTL=0) for the service records.

Source

pub async fn announce(&self)

Send a gratuitous announcement of all registered services.

Source

pub async fn lookup(&self, name: &str, qtype: u16) -> Vec<RR>

Lookup cached records by name and type.

Source

pub async fn active_lookup(&self, name: &str, qtype: u16)

Source

pub fn shutdown(&self)

Shut down all background tasks.

Trait Implementations§

Source§

impl Drop for MdnsService

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V