rust-embedded-community / embedded-nal

An Embedded Network Abstraction Layer
Apache License 2.0
177 stars 25 forks source link

Refactoring DNS to base trait #107

Open ryan-summers opened 1 month ago

ryan-summers commented 1 month ago

This PR refactors the network stack traits around DNS to change the implementation details.

The driving reason behind this is to align it more closely with std-based targets. Specifically, DNS implementation details are not exposed to the user, and if DNS services are not available, DNS resolution will Err.

This discussion came about as a result of https://github.com/quartiq/minimq/issues/160, where we discussed the fact that there's two bounds required in our MQTT implementation.

I'm curious to hear feedback on this from other users of the DNS traits, CC @chrysn and @MathiasKoch

The intent here is to make DNS more of a "first class citizen" that is available for usage by all users. That way, client libraries that can take either an IP or a hostname can attempt resolution of the name and use the reuslt without requiring additional Dns trait bounds.


This is essentially solidifying some implementation details. For example, the smoltcp-nal already implements the Dns trait, but it only provides non-Err results if the user has set up the Smoltcp sockets with a DNS socket for processing. Thus, the trait bound isn't actually providing any value in protecting users from a missing DNS implementation.