pub trait Isolation: Sealed + Downcast + DynClone + Debug + Send + Sync + 'static {
    // Required methods
    fn compatible(&self, other: &dyn Isolation) -> bool;
    fn join(&self, other: &dyn Isolation) -> Option<Box<dyn Isolation>>;
}
Expand description

A type that can make isolation decisions about streams it is attached to.

Types that implement Isolation contain properties about a stream that are used to make decisions about whether that stream can share the same circuit as other streams. You may pass in any type implementing Isolation when creating a stream via TorClient::connect_with_prefs, or constructing a circuit with CircMgr::get_or_launch_exit().

You typically do not want to implement this trait directly. Instead, most users should implement IsolationHelper.

Required Methods§

source

fn compatible(&self, other: &dyn Isolation) -> bool

Return true if this Isolation is compatible with another.

Two streams may share a circuit if and only if they have compatible Isolations.

§Requirements

For correctness, this relation must be symmetrical and reflexive: self.compatible(other) must equal other.compatible(self), and self.compatible(self) must be true.

For correctness, this function must always give the same result as self.join(other).is_some().

This relationship does not have to be transitive: it’s possible that stream A can share a circuit with either stream B or stream C, but not with both.

source

fn join(&self, other: &dyn Isolation) -> Option<Box<dyn Isolation>>

Join two Isolation into the intersection of what each allows.

A circuit’s isolation is the join of the isolation values of all of the streams that have ever used that circuit. A circuit’s isolation can never be None: streams that would cause it to be None can’t be attached to the circuit.

When a stream is added to a circuit, join is used to calculate the circuit’s new isolation.

§Requirements

For correctness, this function must be commutative: self.join(other) must equal other.join(self). Also, it must be idempotent: self.join(self) must equal self.

Implementations§

source§

impl dyn Isolation

source

pub fn is<__T: Isolation>(&self) -> bool

Returns true if the trait object wraps an object of type __T.

source

pub fn downcast<__T: Isolation>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn’t.

source

pub fn downcast_rc<__T: Isolation>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn’t.

source

pub fn downcast_ref<__T: Isolation>(&self) -> Option<&__T>

Returns a reference to the object within the trait object if it is of type __T, or None if it isn’t.

source

pub fn downcast_mut<__T: Isolation>(&mut self) -> Option<&mut __T>

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn’t.

Trait Implementations§

source§

impl<T: Isolation> From<T> for Box<dyn Isolation>

source§

fn from(isolation: T) -> Self

Converts to this type from the input type.

Implementors§

source§

impl<T: IsolationHelper + Clone + Debug + Send + Sync + 'static> Isolation for T