pub struct Socket<'a> { /* private fields */ }
Expand description
A Domain Name System socket.
A UDP socket is bound to a specific endpoint, and owns transmit and receive packet buffers.
Implementations§
Source§impl<'a> Socket<'a>
impl<'a> Socket<'a>
Sourcepub fn new<Q>(servers: &[Address], queries: Q) -> Socket<'a>
pub fn new<Q>(servers: &[Address], queries: Q) -> Socket<'a>
Create a DNS socket.
Truncates the server list if servers.len() > MAX_SERVER_COUNT
Sourcepub fn update_servers(&mut self, servers: &[Address])
pub fn update_servers(&mut self, servers: &[Address])
Update the list of DNS servers, will replace all existing servers
Truncates the server list if servers.len() > MAX_SERVER_COUNT
Sourcepub fn hop_limit(&self) -> Option<u8>
pub fn hop_limit(&self) -> Option<u8>
Return the time-to-live (IPv4) or hop limit (IPv6) value used in outgoing packets.
See also the set_hop_limit method
Sourcepub fn set_hop_limit(&mut self, hop_limit: Option<u8>)
pub fn set_hop_limit(&mut self, hop_limit: Option<u8>)
Set the time-to-live (IPv4) or hop limit (IPv6) value used in outgoing packets.
A socket without an explicitly set hop limit value uses the default IANA recommended value (64).
§Panics
This function panics if a hop limit value of 0 is given. See RFC 1122 § 3.2.1.7.
Sourcepub fn start_query(
&mut self,
cx: &mut InterfaceInner,
name: &str,
query_type: Type,
) -> Result<QueryHandle, StartQueryError>
pub fn start_query( &mut self, cx: &mut InterfaceInner, name: &str, query_type: Type, ) -> Result<QueryHandle, StartQueryError>
Start a query.
name
is specified in human-friendly format, such as "rust-lang.org"
.
It accepts names both with and without trailing dot, and they’re treated
the same (there’s no support for DNS search path).
Sourcepub fn start_query_raw(
&mut self,
cx: &mut InterfaceInner,
raw_name: &[u8],
query_type: Type,
mdns: MulticastDns,
) -> Result<QueryHandle, StartQueryError>
pub fn start_query_raw( &mut self, cx: &mut InterfaceInner, raw_name: &[u8], query_type: Type, mdns: MulticastDns, ) -> Result<QueryHandle, StartQueryError>
Start a query with a raw (wire-format) DNS name.
b"\x09rust-lang\x03org\x00"
You probably want to use [start_query
] instead.
Sourcepub fn get_query_result(
&mut self,
handle: QueryHandle,
) -> Result<Vec<Address, smoltcp::::socket::dns::{impl#3}::get_query_result::{constant#0}>, GetQueryResultError>
pub fn get_query_result( &mut self, handle: QueryHandle, ) -> Result<Vec<Address, smoltcp::::socket::dns::{impl#3}::get_query_result::{constant#0}>, GetQueryResultError>
Get the result of a query.
If the query is completed, the query slot is automatically freed.
§Panics
Panics if the QueryHandle corresponds to a free slot.
Sourcepub fn cancel_query(&mut self, handle: QueryHandle)
pub fn cancel_query(&mut self, handle: QueryHandle)
Cancels a query, freeing the slot.
§Panics
Panics if the QueryHandle corresponds to an already free slot.
Sourcepub fn register_query_waker(&mut self, handle: QueryHandle, waker: &Waker)
pub fn register_query_waker(&mut self, handle: QueryHandle, waker: &Waker)
Assign a waker to a query slot
The waker will be woken when the query completes, either successfully or failed.
§Panics
Panics if the QueryHandle corresponds to an already free slot.