pub struct OneShotMdnsResolver { /* private fields */ }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::sync_discovery::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§
Source§impl OneShotMdnsResolver
impl OneShotMdnsResolver
Sourcepub fn new() -> Result<Self, SimpleMdnsError>
pub fn new() -> Result<Self, SimpleMdnsError>
Creates a new OneShotMdnsResolver using IP V4 with unspecified interface
Sourcepub fn new_with_scope(
network_scope: NetworkScope,
) -> Result<Self, SimpleMdnsError>
pub fn new_with_scope( network_scope: NetworkScope, ) -> Result<Self, SimpleMdnsError>
Creates a new OneShotMdnsResolver with the specified scope
Sourcepub fn query_packet(
&self,
packet: Packet<'_>,
) -> Result<Option<Vec<u8>>, SimpleMdnsError>
pub fn query_packet( &self, packet: Packet<'_>, ) -> Result<Option<Vec<u8>>, SimpleMdnsError>
Send a query packet and returns the first response
Sourcepub 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
Sourcepub 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
Sourcepub fn set_query_timeout(&mut self, query_timeout: Duration)
pub fn set_query_timeout(&mut self, query_timeout: Duration)
Set the one shot mdns resolver’s query timeout.
Sourcepub fn set_unicast_response(&mut self, unicast_response: bool)
pub fn set_unicast_response(&mut self, unicast_response: bool)
Set the one shot mdns resolver’s unicast response.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OneShotMdnsResolver
impl RefUnwindSafe for OneShotMdnsResolver
impl Send for OneShotMdnsResolver
impl Sync for OneShotMdnsResolver
impl Unpin for OneShotMdnsResolver
impl UnsafeUnpin for OneShotMdnsResolver
impl UnwindSafe for OneShotMdnsResolver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more