Sign in

    chgttyyr/moon_dns/src/types does not have a README file

    DnsError

    pub(all) enum DnsError {
    BufferUnderflow(String)
    BufferOverflow(String)
    MalformedLabel(String)
    MalformedPointer(String)
    InvalidLength(String)
    InvalidCharacter(String)
    UnsupportedType(UInt16)
    ProtocolError(String)
    IoError(String)
    } derive(Eq,
    Debug
    )

    DnsError represents all protocol, parsing, and serialization error variants.

    DnsError::message

    fn DnsError::message(self : DnsError) -> String

    Returns a human-readable description of the DNS error.
    pub(all) struct Header {
    id : UInt16
    qr : Bool
    opcode : OpCode
    aa : Bool
    tc : Bool
    rd : Bool
    ra : Bool
    z : Byte
    rcode : RCode
    qdcount : UInt16
    ancount : UInt16
    nscount : UInt16
    arcount : UInt16
    } derive(Eq,
    Debug
    )

    DNS Message Header (12 bytes fixed size, RFC 1035 Section 4.1.1)

    Header::new_query

    fn Header::new_query(id : UInt16) -> Header

    Default constructor for a new DNS query header

    Header::new_response

    fn Header::new_response(id : UInt16, aa : Bool, rcode : RCode, qdcount : UInt16, ancount : UInt16, nscount : UInt16, arcount : UInt16) -> Header

    Construct an authoritative response header responding to a query

    Message

    pub(all) struct Message {
    header : Header
    questions : Array[Question]
    answers : Array[Record]
    authorities : Array[Record]
    additionals : Array[Record]
    } derive(Eq,
    Debug
    )

    Complete DNS Message structure (RFC 1035 Section 4.1)

    Message::add_additional

    fn Message::add_additional(self : Message, record : Record) -> Unit

    Append an additional record

    Message::add_answer

    fn Message::add_answer(self : Message, record : Record) -> Unit

    Append an answer record

    Message::add_authority

    fn Message::add_authority(self : Message, record : Record) -> Unit

    Append an authority record

    Message::new

    fn Message::new() -> Message

    Constructor for an empty Message with default header

    Message::new_query

    fn Message::new_query(id : UInt16, name : String, qtype : RType) -> Message

    Construct a standard DNS query message for a domain and type

    Message::new_response

    fn Message::new_response(query : Message, aa : Bool, rcode : RCode) -> Message

    Construct a response message referencing an incoming query

    Message::sync_counts

    fn Message::sync_counts(self : Message) -> Unit

    Synchronize counts in header with actual record arrays

    OpCode

    pub(all) enum OpCode {
    Query
    IQuery
    Status
    Notify
    Update
    Unknown(Byte)
    } derive(Eq,
    Debug
    )

    DNS Operation Codes (RFC 1035)

    OpCode::from_wire

    fn OpCode::from_wire(val : Byte) -> OpCode

    Parse OpCode from wire protocol byte

    OpCode::to_wire

    fn OpCode::to_wire(self : OpCode) -> Byte

    Convert OpCode to wire protocol byte

    Question

    pub(all) struct Question {
    name : String
    qtype : RType
    qclass : RClass
    } derive(Eq,
    Debug
    )

    DNS Question Entry (RFC 1035 Section 4.1.2)

    Question::new

    fn Question::new(name : String, qtype : RType, qclass : RClass) -> Question

    Create a new Question instance

    RClass

    pub(all) enum RClass {
    IN
    CS
    CH
    HS
    NONE
    ANY
    Unknown(UInt16)
    } derive(Eq,
    Debug
    )

    DNS Record Classes (RFC 1035 Section 3.2.4)

    RClass::from_wire

    fn RClass::from_wire(code : UInt16) -> RClass

    Parse RClass from wire protocol 16-bit integer

    RClass::to_string

    fn RClass::to_string(self : RClass) -> String

    Convert RClass to human-readable string representation

    RClass::to_wire

    fn RClass::to_wire(self : RClass) -> UInt16

    Convert RClass to wire protocol 16-bit integer

    RCode

    pub(all) enum RCode {
    NoError
    FormErr
    ServFail
    NXDomain
    NotImp
    Refused
    YXDomain
    YXRRSet
    NXRRSet
    NotAuth
    NotZone
    BadVers
    Unknown(UInt16)
    } derive(Eq,
    Debug
    )

    DNS Response Codes (RFC 1035 / RFC 6891)

    RCode::from_wire

    fn RCode::from_wire(code : UInt16) -> RCode

    Parse RCode from wire protocol integer

    RCode::to_wire

    fn RCode::to_wire(self : RCode) -> UInt16

    Convert RCode to wire protocol integer

    RData

    pub(all) enum RData {
    A(Byte, Byte, Byte, Byte)
    AAAA(FixedArray[Byte])
    CNAME(String)
    NS(String)
    PTR(String)
    MX(UInt16, String)
    TXT(Array[String])
    SOA(String, String, UInt, UInt, UInt, UInt, UInt)
    SRV(UInt16, UInt16, UInt16, String)
    CAA(Byte, String, String)
    OPT(UInt16, Byte, Byte, Bool, Bytes)
    Raw(Bytes)
    } derive(Eq,
    Debug
    )

    RData payload variants corresponding to each supported DNS RR type

    RData::rtype

    fn RData::rtype(self : RData) -> RType

    Returns the corresponding RType for this RData instance

    RData::to_presentation

    fn RData::to_presentation(self : RData) -> String

    Format RData into standard master file presentation text

    RType

    pub(all) enum RType {
    A
    NS
    CNAME
    SOA
    PTR
    MX
    TXT
    AAAA
    SRV
    OPT
    AXFR
    ANY
    CAA
    Unknown(UInt16)
    } derive(Eq,
    Debug
    )

    DNS Resource Record Types (RFC 1035, RFC 3596, RFC 6891, RFC 6844, etc.)

    RType::from_string

    fn RType::from_string(s : String) -> RType?

    Parse RType from uppercase string representation

    RType::from_wire

    fn RType::from_wire(code : UInt16) -> RType

    Parse RType from wire protocol 16-bit integer

    RType::to_string

    fn RType::to_string(self : RType) -> String

    Convert RType to human-readable string representation

    RType::to_wire

    fn RType::to_wire(self : RType) -> UInt16

    Convert RType to standard wire protocol 16-bit unsigned integer

    Record

    pub(all) struct Record {
    name : String
    rtype : RType
    rclass : RClass
    ttl : UInt
    rdata : RData
    } derive(Eq,
    Debug
    )

    DNS Resource Record (RFC 1035 Section 4.1.3)

    Record::new

    fn Record::new(name : String, rtype : RType, rclass : RClass, ttl : UInt, rdata : RData) -> Record

    Constructor for a standard Record

    format_ipv4

    fn format_ipv4(b0 : Byte, b1 : Byte, b2 : Byte, b3 : Byte) -> String

    Helper to format IPv4 address as dotted quad

    format_ipv6

    fn format_ipv6(bytes : FixedArray[Byte]) -> String

    Helper to format IPv6 address as colon-hex

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io