Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace remaining Box<dyn DnsRecordExt> with type #271

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/dns_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ pub const FLAGS_TC: u16 = 0x0200;

pub(crate) type DnsRecordBox = Box<dyn DnsRecordExt>;

impl Clone for DnsRecordBox {
fn clone(&self) -> Self {
self.clone_box()
}
}

const U16_SIZE: usize = 2;

#[inline]
Expand Down Expand Up @@ -411,13 +417,7 @@ pub(crate) trait DnsRecordExt: fmt::Debug {
false
}

fn clone_box(&self) -> Box<dyn DnsRecordExt>;
}

impl Clone for Box<dyn DnsRecordExt> {
fn clone(&self) -> Box<dyn DnsRecordExt> {
self.clone_box()
}
fn clone_box(&self) -> DnsRecordBox;
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -484,7 +484,7 @@ impl DnsRecordExt for DnsAddress {
format!("{}", self.address)
}

fn clone_box(&self) -> Box<dyn DnsRecordExt> {
fn clone_box(&self) -> DnsRecordBox {
Box::new(self.clone())
}
}
Expand Down Expand Up @@ -546,7 +546,7 @@ impl DnsRecordExt for DnsPointer {
self.alias.clone()
}

fn clone_box(&self) -> Box<dyn DnsRecordExt> {
fn clone_box(&self) -> DnsRecordBox {
Box::new(self.clone())
}
}
Expand Down Expand Up @@ -664,7 +664,7 @@ impl DnsRecordExt for DnsSrv {
)
}

fn clone_box(&self) -> Box<dyn DnsRecordExt> {
fn clone_box(&self) -> DnsRecordBox {
Box::new(self.clone())
}
}
Expand Down Expand Up @@ -737,7 +737,7 @@ impl DnsRecordExt for DnsTxt {
format!("{:?}", decode_txt(&self.text))
}

fn clone_box(&self) -> Box<dyn DnsRecordExt> {
fn clone_box(&self) -> DnsRecordBox {
Box::new(self.clone())
}
}
Expand Down Expand Up @@ -818,7 +818,7 @@ impl DnsRecordExt for DnsHostInfo {
format!("cpu: {}, os: {}", self.cpu, self.os)
}

fn clone_box(&self) -> Box<dyn DnsRecordExt> {
fn clone_box(&self) -> DnsRecordBox {
Box::new(self.clone())
}
}
Expand Down Expand Up @@ -928,7 +928,7 @@ impl DnsRecordExt for DnsNSec {
)
}

fn clone_box(&self) -> Box<dyn DnsRecordExt> {
fn clone_box(&self) -> DnsRecordBox {
Box::new(self.clone())
}
}
Expand Down