radixtarget_rust/node/
dns.rs1use super::base::BaseNode;
2use std::collections::HashMap;
3
4#[derive(Debug, Clone)]
5pub struct DnsNode {
6 pub children: HashMap<u64, Box<DnsNode>>,
7 pub host: Option<String>, }
9
10impl Default for DnsNode {
11 fn default() -> Self {
12 Self::new()
13 }
14}
15
16impl DnsNode {
17 pub fn new() -> Self {
18 DnsNode {
19 children: HashMap::new(),
20 host: None,
21 }
22 }
23}
24
25impl BaseNode for DnsNode {
26 fn is_dead(&self) -> bool {
27 self.host.is_none() && self.children.is_empty()
28 }
29 fn children_mut(&mut self) -> &mut HashMap<u64, Box<DnsNode>> {
30 &mut self.children
31 }
32 fn children(&self) -> &HashMap<u64, Box<DnsNode>> {
33 &self.children
34 }
35 fn host_string(&self) -> Option<String> {
36 self.host.clone()
37 }
38}