fn lookup_impl<'a>(
    node: &'a Node,
    name: &Name,
    level: usize,
    process_referrals: bool,
    at_apex: bool,
) -> LookupAllResult<'a> {
    // If the node has an NS record, that triggers a referral—even when
    // the node is the target node!
    if !at_apex && process_referrals {
        if let Some(ns_rrset) = node.rrsets.lookup(Type::NS) {
            return LookupAllResult::Referral(&node.name, ns_rrset);
        }
    }

    if level == 0 {
        LookupAllResult::Found(&node.rrsets)
    } else {
        // Try to traverse down the tree. If deeper nodes do not exist,
        // then this node is the "closest encloser" (see RFC 4592 §
        // 3.3.1), and we search for a wildcard domain name to be the
        // "source of synthesis" for the response.
        if let Some(subnode) = node.children.get(&name[level - 1]) {
            lookup_impl(subnode, name, level - 1, process_referrals, false)
        } else if let Some(source_of_synthesis) = node.children.get(Label::asterisk()) {
            LookupAllResult::Found(&source_of_synthesis.rrsets)
        } else {
            LookupAllResult::NxDomain
        }
    }
}
/// Implements the DNS lookup algorithm.
///
/// `node` is the deepest node we have matched so far; this node
/// corresponds to the label `name[level]`. If we have not reached the
/// target node, the function attempts to recursively match down the
/// tree. When `process_referrals` is `true`, a non-apex node with an NS
/// record will result in a referral; otherwise, the search will
/// continue into non-authoritative data. We need to keep track of whether
/// we're at the zone apex, so the first call should set `at_apex` to
/// `true`.
Implements the DNS lookup algorithm.
`node` is the deepest node we have matched so far; this node
corresponds to the label `name[level]`. If we have not reached the
target node, the function attempts to recursively match down the
tree. When `process_referrals` is `true`, a non-apex node with an NS
record will result in a referral; otherwise, the search will
continue into non-authoritative data. We need to keep track of whether
we're at the zone apex, so the first call should set `at_apex` to
`true`.
Implements the DNS lookup algorithm . ` node ` is the deepest node we have matched so far ; this node corresponds to the label ` name [ level ] ` . If we have not reached the target node the function attempts to recursively match down the tree . When ` process_referrals ` is ` true ` a non - apex node with an NS record will result in a referral ; otherwise the search will continue into non - authoritative data . We need to keep track of whether we ' re at the zone apex so the first call should set ` at_apex ` to ` true ` .
fn lookup_impl<'a>(
    node: &'a Node,
    name: &Name,
    level: usize,
    process_referrals: bool,
    at_apex: bool,
) -> LookupAllResult<'a> {
    // If the node has an NS record, that triggers a referral—even when
    // the node is the target node!
    if !at_apex && process_referrals {
        if let Some(ns_rrset) = node.rrsets.lookup(Type::NS) {
            return LookupAllResult::Referral(&node.name, ns_rrset);
        }
    }
    if level == 0 {
        LookupAllResult::Found(&node.rrsets)
    } else {
        // Try to traverse down the tree. If deeper nodes do not exist,
        // then this node is the "closest encloser" (see RFC 4592 §
        // 3.3.1), and we search for a wildcard domain name to be the
        // "source of synthesis" for the response.
        if let Some(subnode) = node.children.get(&name[level - 1]) {
            lookup_impl(subnode, name, level - 1, process_referrals, false)
        } else if let Some(source_of_synthesis) = node.children.get(Label::asterisk()) {
            LookupAllResult::Found(&source_of_synthesis.rrsets)
        } else {
            LookupAllResult::NxDomain
        }
    }
}
fn lookup_impl < ' a > ( node : & ' a Node , name : & Name , level : usize , process_referrals : bool , at_apex : bool , ) -> LookupAllResult < ' a > { // If the node has an NS record, that triggers a referral—even when // the node is the target node! if ! at_apex && process_referrals { if let Some ( ns_rrset ) = node . rrsets . lookup ( Type :: NS ) { return LookupAllResult :: Referral ( & node . name , ns_rrset ) ; } } if level == 0 { LookupAllResult :: Found ( & node . rrsets ) } else { // Try to traverse down the tree. If deeper nodes do not exist, // then this node is the "closest encloser" (see RFC 4592 § // 3.3.1), and we search for a wildcard domain name to be the // "source of synthesis" for the response. if let Some ( subnode ) = node . children . get ( & name [ level - 1 ] ) { lookup_impl ( subnode , name , level - 1 , process_referrals , false ) } else if let Some ( source_of_synthesis ) = node . children . get ( Label :: asterisk ( ) ) { LookupAllResult :: Found ( & source_of_synthesis . rrsets ) } else { LookupAllResult :: NxDomain } } }
Implements the DNS lookup algorithm.
Implements the DNS lookup algorithm .
node
&'a Node
name
&Name
level
usize
process_referrals
bool
at_apex
bool
node
&'a Node
name
&Name
level
usize
process_referrals
bool
at_apex
bool