[][src]Struct toluol::DnsMessage

pub struct DnsMessage {
    pub header: DnsHeader,
    // some fields omitted
}

Represents a DNS message. See RFC 1035 for further information.

Fields

header: DnsHeader

Implementations

impl DnsMessage[src]

pub fn new_query(
    domain: &str,
    qtype: DnsType,
    opcode: DnsOpcode,
    rd: bool,
    ad: bool,
    cd: bool,
    edns: bool,
    do_flag: bool,
    bufsize: u16
) -> Result<DnsMessage>
[src]

Creates a DNS query. edns dictates whether the query contains an OPT record for indication of EDNS support. bufsize is the payload size that gets sent in the OPT record. If edns == false the value of bufsize is ignored. do_flag indicates DNSSEC support. See RFC 1035 and the documentation of DnsHeader for information about the remaining parameters. Returns an error if do_flag && !edns == true.

pub fn new_response(
    msg_id: u16,
    opcode: DnsOpcode,
    aa: bool,
    tc: bool,
    rd: bool,
    ra: bool,
    ad: bool,
    cd: bool,
    rcode: DnsRcode,
    questions: Vec<DnsQuestion>,
    answers: Vec<DnsRecord>,
    authoritative_answers: Vec<DnsRecord>,
    additional_answers: Vec<DnsRecord>
) -> DnsMessage
[src]

Creates a DNS response. See the documentation of DnsHeader for information about the parameters.

pub fn encode(&self) -> Result<Vec<u8>>[src]

Encodes a DnsMessage as a series of bytes. Returns an error if DnsHeader::encode(), DnsQuestion::encode() or DnsRecord::encode() return an error.

pub fn parse(msg: &mut Cursor<&[u8]>) -> Result<DnsMessage>[src]

Parses an encoded DnsMessage from a series of bytes. Returns an error if DnsHeader::parse(), DnsQuestion::parse() or DnsRecord::parse() return an error, the header/EDNS header contain an RCODE other than DnsRcode::NoError or a truncated message is received.

pub fn encode_qname(domain: &str) -> Result<Vec<u8>>[src]

Encodes a domain name as a DNS QNAME. Does not use message compression. Returns an error if the domain name is longer than 255 characters, a label (part between two dots) in the domain name is longer than 63 characters or a method defined in byteorder::WriteBytesExt returns an error.

pub fn parse_string(msg: &mut Cursor<&[u8]>) -> Result<String>[src]

Parses a character string as defined by RFC 1035. Returns an error if a method defined in byteorder::ReadBytesExt returns an error.

pub fn parse_qname(msg: &mut Cursor<&[u8]>) -> Result<String>[src]

Parses a DNS QNAME as defined by RFC 1035, returning it in common url format. As required by the specification, method compression is supported. Returns an error if a method defined in byteorder::ReadBytesExt returns an error or an extended or invalid label type is encountered.

Trait Implementations

impl Display for DnsMessage[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,