pub enum DnsRecord {
A(DnsName, Ipv4Addr),
AAAA(DnsName, Ipv6Addr),
CNAME(DnsName, DnsName),
NS(DnsName, DnsName),
TXT(DnsName, Vec<DnsString>),
Unknown(DnsName, DnsType),
}Expand description
4.1.3. Resource record format
The answer, authority, and additional sections all share the same format: a variable number of resource records, where the number of records is specified in the corresponding count field in the header. Each resource record has the following format:
1 1 1 1 1 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | / / / NAME / | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TYPE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | CLASS | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | TTL | | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | RDLENGTH | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--| / RDATA / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+where:
- NAME: a domain name to which this resource record pertains.
- TYPE: two octets containing one of the RR type codes. This field specifies the meaning of the data in the RDATA field.
- CLASS: two octets which specify the class of the data in the RDATA field.
- TTL: a 32 bit unsigned integer that specifies the time interval (in seconds) that the resource record may be cached before it should be discarded. Zero values are interpreted to mean that the RR can only be used for the transaction in progress, and should not be cached.
- RDLENGTH: an unsigned 16 bit integer that specifies the length in octets of the RDATA field.
- RDATA: a variable length string of octets that describes the resource. The format of this information varies according to the TYPE and CLASS of the resource record. For example, the if the TYPE is A and the CLASS is IN, the RDATA field is a 4 octet ARPA Internet address.
Variants§
A(DnsName, Ipv4Addr)
AAAA(DnsName, Ipv6Addr)
CNAME(DnsName, DnsName)
NS(DnsName, DnsName)
TXT(DnsName, Vec<DnsString>)
3.3.14. TXT RDATA format TXT-DATA = One or more
s. TXT RRs are used to hold descriptive text. The semantics of the text depends on the domain where it is found.
https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.14
Unknown(DnsName, DnsType)
Implementations§
Source§impl DnsRecord
impl DnsRecord
Sourcepub fn read_rdata<const N: usize>(
buf: &mut FixedBuf<N>,
) -> Result<FixedBuf<65535>, DnsError>
pub fn read_rdata<const N: usize>( buf: &mut FixedBuf<N>, ) -> Result<FixedBuf<65535>, DnsError>
§Errors
Returns an error when buf does not contain a valid resource record.
Sourcepub fn write_rdata<const N: usize>(
bytes: &[u8],
out: &mut FixedBuf<N>,
) -> Result<(), DnsError>
pub fn write_rdata<const N: usize>( bytes: &[u8], out: &mut FixedBuf<N>, ) -> Result<(), DnsError>
§Errors
Returns an error when buf is full or bytes is longer than 65,535 bytes.
Sourcepub fn new_a(name: &str, ipv4_addr: &str) -> Result<Self, String>
pub fn new_a(name: &str, ipv4_addr: &str) -> Result<Self, String>
§Errors
Returns an error when name is not a valid DNS name
or ipv4_addr is not a valid IPv4 address.
Sourcepub fn new_aaaa(name: &str, ipv6_addr: &str) -> Result<Self, String>
pub fn new_aaaa(name: &str, ipv6_addr: &str) -> Result<Self, String>
§Errors
Returns an error when name is not a valid DNS name
or ipv6_addr is not a valid IPv6 address.
Sourcepub fn new_cname(name: &str, target: &str) -> Result<Self, String>
pub fn new_cname(name: &str, target: &str) -> Result<Self, String>
§Errors
Returns an error when name or target are not both valid DNS names.
Sourcepub fn new_ns(name: &str, target: &str) -> Result<Self, String>
pub fn new_ns(name: &str, target: &str) -> Result<Self, String>
§Errors
Returns an error when name or target are not both valid DNS names.
Sourcepub fn new_txt(name: &str, content: &str) -> Result<Self, String>
pub fn new_txt(name: &str, content: &str) -> Result<Self, String>
§Errors
Returns an error when name or target are not both valid DNS names.
Sourcepub fn new_txt_multi(name: &str, lines: &[&str]) -> Result<Self, String>
pub fn new_txt_multi(name: &str, lines: &[&str]) -> Result<Self, String>
§Errors
Returns an error when name or target are not both valid DNS names.