Enum dns_server::DnsRecord
source · pub enum DnsRecord {
A(DnsName, Ipv4Addr),
AAAA(DnsName, Ipv6Addr),
CNAME(DnsName, DnsName),
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§
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.
pub fn name(&self) -> &DnsName
pub fn typ(&self) -> DnsType
Trait Implementations§
source§impl Ord for DnsRecord
impl Ord for DnsRecord
source§impl PartialEq for DnsRecord
impl PartialEq for DnsRecord
source§impl PartialOrd for DnsRecord
impl PartialOrd for DnsRecord
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Eq for DnsRecord
impl StructuralPartialEq for DnsRecord
Auto Trait Implementations§
impl Freeze for DnsRecord
impl RefUnwindSafe for DnsRecord
impl Send for DnsRecord
impl Sync for DnsRecord
impl Unpin for DnsRecord
impl UnwindSafe for DnsRecord
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more