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 ipv6

Implementations

Creates a new OneShotMdnsResolver

Send a query packet and returns the first response

Send a query for A or AAAA (IP v4 and v6 respectively) resources and return the first address

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.

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.