Browse Source

allow converting Box<dyn RRData> to Box<dyn Any> for owned downcast

preview
Stefan Bühler 2 years ago
parent
commit
ff13630b8c
  1. 4
      lib/dnsbox-base/src/records/unknown.rs
  2. 2
      lib/dnsbox-base/src/ser/rrdata.rs
  3. 4
      lib/dnsbox-derive/src/rrdata.rs

4
lib/dnsbox-base/src/records/unknown.rs

@ -117,4 +117,8 @@ impl RRData for UnknownRecord {
fn as_any(&self) -> &dyn ::std::any::Any {
self as _
}
fn as_box_any(self: Box<Self>) -> Box<dyn ::std::any::Any> {
self as _
}
}

2
lib/dnsbox-base/src/ser/rrdata.rs

@ -108,6 +108,8 @@ pub trait RRData: RRDataPacket + RRDataText + fmt::Debug + 'static {
fn as_any(&self) -> &dyn Any;
fn as_box_any(self: Box<Self>) -> Box<dyn Any>;
// (type, rrdata)
fn text(&self) -> Result<(String, String)> {
let mut buf = String::new();

4
lib/dnsbox-derive/src/rrdata.rs

@ -66,6 +66,10 @@ pub fn rrdata_derive(s: synstructure::Structure) -> proc_macro2::TokenStream {
fn as_any(&self) -> &::std::any::Any {
self as _
}
fn as_box_any(self: Box<Self>) -> Box<dyn ::std::any::Any> {
self as _
}
},
);

Loading…
Cancel
Save