mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
Expose api on Stack and add doc
Make it work with smoltcp 0.9
This commit is contained in:
parent
cd440a49d6
commit
7ae47cb1d8
@ -1,6 +1,6 @@
|
||||
//! DNS socket with async support.
|
||||
use heapless::Vec;
|
||||
pub use smoltcp::socket::dns::{DnsQuery, Socket, MAX_ADDRESS_COUNT};
|
||||
pub use smoltcp::socket::dns::{DnsQuery, Socket};
|
||||
pub(crate) use smoltcp::socket::dns::{GetQueryResultError, StartQueryError};
|
||||
pub use smoltcp::wire::{DnsQueryType, IpAddress};
|
||||
|
||||
@ -48,9 +48,7 @@ impl<'a, D> DnsSocket<'a, D>
|
||||
where
|
||||
D: Driver + 'static,
|
||||
{
|
||||
/// Create a new DNS socket using the provided stack and query storage.
|
||||
///
|
||||
/// DNS servers are derived from the stack configuration.
|
||||
/// Create a new DNS socket using the provided stack.
|
||||
///
|
||||
/// NOTE: If using DHCP, make sure it has reconfigured the stack to ensure the DNS servers are updated.
|
||||
pub fn new(stack: &'a Stack<D>) -> Self {
|
||||
@ -58,7 +56,7 @@ where
|
||||
}
|
||||
|
||||
/// Make a query for a given name and return the corresponding IP addresses.
|
||||
pub async fn query(&self, name: &str, qtype: DnsQueryType) -> Result<Vec<IpAddress, MAX_ADDRESS_COUNT>, Error> {
|
||||
pub async fn query(&self, name: &str, qtype: DnsQueryType) -> Result<Vec<IpAddress, 1>, Error> {
|
||||
self.stack.dns_query(name, qtype).await
|
||||
}
|
||||
}
|
||||
|
@ -231,12 +231,9 @@ impl<D: Driver + 'static> Stack<D> {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
/// Make a query for a given name and return the corresponding IP addresses.
|
||||
#[cfg(feature = "dns")]
|
||||
async fn dns_query(
|
||||
&self,
|
||||
name: &str,
|
||||
qtype: dns::DnsQueryType,
|
||||
) -> Result<Vec<IpAddress, { dns::MAX_ADDRESS_COUNT }>, dns::Error> {
|
||||
pub async fn dns_query(&self, name: &str, qtype: dns::DnsQueryType) -> Result<Vec<IpAddress, 1>, dns::Error> {
|
||||
let query = self.with_mut(|s, i| {
|
||||
if let Some(dns_handle) = i.dns_socket {
|
||||
let socket = s.sockets.get_mut::<dns::Socket>(dns_handle);
|
||||
|
Loading…
Reference in New Issue
Block a user