Struct simple_mdns::ServiceDiscovery[][src]

pub struct ServiceDiscovery { /* fields omitted */ }
Expand description

Service Discovery implementation using DNS-SD. This implementation advertise all the registered addresses, query for the same service on the same network and keeps a cache of known service instances

Notice that this crate does not provide any means of finding your own ip address. There are crates that provide this kind of feature.

Example

use simple_mdns::ServiceDiscovery;
use std::net::SocketAddr;
use std::str::FromStr;

let mut discovery = ServiceDiscovery::new("a", "_mysrv._tcp.local", 60).expect("Invalid Service Name");
discovery.add_service_info(SocketAddr::from_str("192.168.1.22:8090").unwrap().into());

Implementations

Creates a new ServiceDiscovery by providing instance, service_name, resource ttl and loopback activation. instance_name and service_name will be composed together in order to advertise this instance, like instance_name.service_name

instance_name must be in the standard specified by the mdns RFC and short, example: _my_inst service_name must be in the standard specified by the mdns RFC, example: _my_service._tcp.local resource_ttl refers to the amount of time in seconds your service will be cached in the dns responder. set enable_loopback to true if you may have more than one instance of your service running in the same machine

Add the service info to discovery and immediately advertise the service

Remove all addresses from service discovery

Return the addresses of all known services

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.