Struct simple_mdns::OneShotMdnsResolver [−][src]
pub struct OneShotMdnsResolver { /* fields omitted */ }Expand description
Provides One Shot queries (legacy mDNS)
Every query will timeout after query_timeout elapses (defaults to 3 seconds)
One Shot queries returns only the first valid response to arrive
use simple_mdns::OneShotMdnsResolver;
use std::time::Duration;
let mut resolver = OneShotMdnsResolver::new().expect("Can't create one shot resolver");
resolver.set_query_timeout(Duration::from_secs(1));
// querying for IP Address
let answer = resolver.query_service_address("_myservice._tcp.local").expect("Failed to query service address");
println!("{:?}", answer);
// IpV4Addr or IpV6Addr, depending on what was returned
let answer = resolver.query_service_address_and_port("_myservice._tcp.local").expect("Failed to query service address and port");
println!("{:?}", answer);
// SocketAddr, "127.0.0.1:8080", with a ipv4 or ipv6Implementations
Creates a new OneShotMdnsResolver
Send a query packet and returns the first response
pub fn query_service_address(
&self,
service_name: &str
) -> Result<Option<IpAddr>, SimpleMdnsError>
pub fn query_service_address(
&self,
service_name: &str
) -> Result<Option<IpAddr>, SimpleMdnsError>
Send a query for A or AAAA (IP v4 and v6 respectively) resources and return the first address
pub fn query_service_address_and_port(
&self,
service_name: &str
) -> Result<Option<SocketAddr>, SimpleMdnsError>
pub fn query_service_address_and_port(
&self,
service_name: &str
) -> Result<Option<SocketAddr>, SimpleMdnsError>
Send a query for SRV resources and return the first address and port
Set the one shot mdns resolver’s query timeout.
Set the one shot mdns resolver’s unicast response.