Commit 70f71ac9 authored by trinity-1686a's avatar trinity-1686a
Browse files

seal trait Isolation

parent de5f517d
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -114,7 +114,9 @@ impl Display for TargetPorts {
/// users should implement [`IsolationHelper`].
///
// TODO this trait should probably be sealed so the same-type requirement can't be bypassed
pub trait Isolation: Downcast + DynClone + std::fmt::Debug + Send + Sync + 'static {
pub trait Isolation:
    seal::Sealed + Downcast + DynClone + std::fmt::Debug + Send + Sync + 'static
{
    /// Return true if this Isolation is compatible with another.
    ///
    /// Two streams may share a circuit if and only if they have compatible
@@ -154,6 +156,14 @@ pub trait Isolation: Downcast + DynClone + std::fmt::Debug + Send + Sync + 'stat
    // all the math.)
    fn join(&self, other: &dyn Isolation) -> Option<Box<dyn Isolation>>;
}

/// Seal preventing implementation of Isolation not relying on IsolationHelper
mod seal {
    /// Seal preventing implementation of Isolation not relying on IsolationHelper
    pub trait Sealed {}
    impl<T: super::IsolationHelper> Sealed for T {}
}

impl_downcast!(Isolation);
clone_trait_object!(Isolation);
impl<T: Isolation> From<T> for Box<dyn Isolation> {