Struct mdns_sd::ServiceDaemon
source · [−]pub struct ServiceDaemon { /* private fields */ }Expand description
A daemon thread for mDNS
This struct provides a handle and an API to the daemon. It is cloneable.
Implementations
sourceimpl ServiceDaemon
impl ServiceDaemon
sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new daemon and spawns a thread to run the daemon.
The daemon (re)uses the default mDNS port 5353. To keep it simple, we don’t ask callers to set the port.
sourcepub fn browse(&self, service_type: &str) -> Result<Receiver<ServiceEvent>>
pub fn browse(&self, service_type: &str) -> Result<Receiver<ServiceEvent>>
Starts browsing for a specific service type.
Returns a channel Receiver to receive events about the service. The caller
can call .recv_async().await on this receiver to handle events in an
async environment or call .recv() in a sync environment.
When a new instance is found, the daemon automatically tries to resolve, i.e. finding more details, i.e. SRV records and TXT records.
sourcepub fn stop_browse(&self, ty_domain: &str) -> Result<()>
pub fn stop_browse(&self, ty_domain: &str) -> Result<()>
Stops searching for a specific service type.
When an error is returned, the caller should retry only when
the error is Error::Again, otherwise should log and move on.
sourcepub fn register(&self, service_info: ServiceInfo) -> Result<()>
pub fn register(&self, service_info: ServiceInfo) -> Result<()>
Registers a service provided by this host.
sourcepub fn unregister(&self, fullname: &str) -> Result<Receiver<UnregisterStatus>>
pub fn unregister(&self, fullname: &str) -> Result<Receiver<UnregisterStatus>>
Unregisters a service. This is a graceful shutdown of a service.
Returns a channel receiver that is used to receive the status code of the unregister.
When an error is returned, the caller should retry only when
the error is Error::Again, otherwise should log and move on.
sourcepub fn shutdown(&self) -> Result<()>
pub fn shutdown(&self) -> Result<()>
Shuts down the daemon thread.
When an error is returned, the caller should retry only when
the error is Error::Again, otherwise should log and move on.
sourcepub fn get_metrics(&self) -> Result<Receiver<Metrics>>
pub fn get_metrics(&self) -> Result<Receiver<Metrics>>
Returns a channel receiver for the metrics, e.g. input/output counters.
The metrics returned is a snapshot. Hence the caller should call this method repeatedly if they want to monitor the metrics continuously.
Trait Implementations
sourceimpl Clone for ServiceDaemon
impl Clone for ServiceDaemon
sourcefn clone(&self) -> ServiceDaemon
fn clone(&self) -> ServiceDaemon
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
Auto Trait Implementations
impl RefUnwindSafe for ServiceDaemon
impl Send for ServiceDaemon
impl Sync for ServiceDaemon
impl Unpin for ServiceDaemon
impl UnwindSafe for ServiceDaemon
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more