Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/net/dns"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
This package has no source imports.
Error
Enum · Source
RFC 1035 message codec only. Resolver choice, transport, retry, transaction identity entropy, caching, DNSSEC and trust belong to explicit providers.
pub enum Error {
Truncated, InvalidLabel, InvalidPointer, NameTooLong, BufferTooSmall, InvalidMessage, SectionOrder
}
TYPE_A
Constant · Source
pub const TYPE_A: u16 = 1
TYPE_AAAA
Constant · Source
pub const TYPE_AAAA: u16 = 28
CLASS_IN
Constant · Source
pub const CLASS_IN: u16 = 1
Header
Struct · Source
pub struct Header {
pub id: u16
pub flags: u16
pub questions: u16
pub answers: u16
pub authorities: u16
pub additional: u16
}
Header.response
Function · Source
pub fn response(&self) -> bool
Header.truncated
Function · Source
pub fn truncated(&self) -> bool
Header.response_code
Function · Source
pub fn response_code(&self) -> u8
header
Function · Source
pub fn header(packet: &[u8]) -> Header!Error
NameProgress
Struct · Source
pub struct NameProgress {
pub consumed: usize
pub written: usize
}
expand_name
Function · Source
Expand into DNS wire form (length octet, label bytes, …, final zero). Arbitrary label bytes remain unambiguous. Pointers must refer backwards and expansion performs <=128 hops. The expanded wire name is <=255 bytes. On failure output may contain an initialized prefix but no result is valid.
pub fn expand_name(packet: &[u8], start: usize, output: &mut[u8]) -> NameProgress!Error
query
Function · Source
A query accepts ASCII presentation labels without escape syntax; a final dot is allowed. Zero-length interior labels and labels >63 octets are rejected. ID and recursion desired are caller decisions; no ambient entropy or policy.
pub fn query(name: &[u8], id: u16, qtype: u16, recursion: bool, output: &mut[u8]) -> usize!Error
Question
Struct · Source
pub struct Question {
pub name: &[u8]
pub qtype: u16
pub class: u16
}
Record
Struct · Source
pub struct Record {
pub name: &[u8]
pub kind: u16
pub class: u16
pub ttl: u32
pub data: &[u8]
pub data_offset: usize
}
Reader
Struct · Source
pub struct Reader {
// Private implementation fields omitted.
}
Reader.new
Function · Source
pub fn new(packet: &[u8]) -> Reader!Error from(packet)
Reader.position
Function · Source
pub fn position(&self) -> usize
Reader.next_question
Function · Source
pub fn next_question(&mut self, name: &mut[u8]) -> Option<Question>!Error from(self, name)
Reader.next_record
Function · Source
pub fn next_record(&mut self, name: &mut[u8]) -> Option<Record>!Error from(self, name)
Reader.finish
Function · Source
pub fn finish(&self) -> void!Error