The trust-dns crate is a Rust library for constructing, sending, and interpreting DNS protocol messages. It follows RFC 1035 and several later RFCs, while exposing DNS terminology through Rust types. section 8.4.2
A small hostname resolver uses the crate to:
- Serialize structured data into bytes, send it across the network, decode the response, and print the address. section 8.4.2
Constructing an IPv4 query
A resolver creates a message, assigns a random identifier, marks it as a query, adds Query::query(domain_name, RecordType::A), and requests recursion. The completed program accepts a hostname and optional DNS server, such as 1.1.1.1, then returns an IP address.
