Commit 4826d757 authored by trinity-1686a's avatar trinity-1686a
Browse files

use downcast-rs instead of our own AsAny

parent 234291f6
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -869,6 +869,8 @@ dependencies = [
[[package]]
name = "derive_builder"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddd8db2d51ce241afb74f9e5cf9482de69c4b77657c2ddaf78993eda8ce2ce8c"
dependencies = [
 "derive_builder_macro",
]
@@ -876,6 +878,8 @@ dependencies = [
[[package]]
name = "derive_builder_core"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcf03b84d76c5bb011d983c17e2675ab49f5498f121bf1ceae5b5855b4a4dddd"
dependencies = [
 "darling",
 "proc-macro2",
@@ -886,6 +890,8 @@ dependencies = [
[[package]]
name = "derive_builder_macro"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cae44c47bca4fd1eaeda52b3d0eecb664ddcbc0d4e7b238bae7ec2c931646c0"
dependencies = [
 "derive_builder_core",
 "syn",
@@ -974,6 +980,12 @@ dependencies = [
 "winapi 0.3.9",
]

[[package]]
name = "downcast-rs"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"

[[package]]
name = "easy-parallel"
version = "3.2.0"
@@ -3218,6 +3230,7 @@ dependencies = [
 "async-trait",
 "bounded-vec-deque",
 "derive_builder",
 "downcast-rs",
 "educe",
 "futures",
 "futures-await-test",
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ tor-rtcompat = { path="../tor-rtcompat", version = "0.1.0"}
async-trait = "0.1.2"
bounded-vec-deque = "0.1"
derive_builder = "0.11"
downcast-rs = "1.2.0"
educe = "0.4.6"
futures = "0.3.14"
humantime-serde = "1.1.1"
+3 −15
Original line number Diff line number Diff line
//! Code related to tracking what activities a circuit can be used for.

use downcast_rs::{impl_downcast, Downcast};
use rand::Rng;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
@@ -100,27 +101,14 @@ impl Display for TargetPorts {
    }
}

use std::any::Any;

/// TODO
pub trait AsAny {
    /// TODO
    fn as_any(&self) -> &dyn Any;
}

impl<T: 'static> AsAny for T {
    fn as_any(&self) -> &dyn Any {
        self
    }
}

/// TODO
pub trait Isolation: AsAny + std::fmt::Debug + Send + Sync + 'static {
pub trait Isolation: Downcast + std::fmt::Debug + Send + Sync + 'static {
    /// TODO
    fn isolated(&self, other: &dyn Isolation) -> bool;
    /// TODO
    fn join(&self, other: &dyn Isolation) -> JoinResult;
}
impl_downcast!(Isolation);

impl<T: IsolationHelper + std::fmt::Debug + Send + Sync + 'static> Isolation for T {
    fn isolated(&self, other: &dyn Isolation) -> bool {