record
ModuleResource records (RFC 1035 §3.2, §4.1.3) and their data.
Contents
use utopia_dns::message::record::Record;Rust
pub struct RecordA resource record: an owner name, type, class, TTL and data.
The data is in presentation form, as zone files write it: an address
for A and AAAA, a name for CNAME, NS, PTR, MX and SRV
(whose numbers are separate fields), mname rname serial refresh retry expire minimum for SOA, flags tag "value" for CAA, the text for
TXT, and hex for other types. It is checked when the record is
encoded, so a zone may hold templates that are never sent.
Rust
use utopia_dns::message::Record;
let record = Record::new("Mail.Example.com", Record::TYPE_MX)
.with_ttl(3600)
.with_rdata("mail.exchange.example.com")
.with_priority(10);
assert_eq!(record.name(), b"mail.example.com");
let wire = record.encode()?;
let (decoded, _) = Record::decode(&wire, 0)?;
assert_eq!(decoded, record);