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