arti_client::isolation

Trait Isolation

pub trait Isolation:
    Sealed
    + Downcast
    + DynClone
    + Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn compatible(&self, other: &(dyn Isolation + 'static)) -> bool;
    fn join(
        &self,
        other: &(dyn Isolation + 'static),
    ) -> 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§

fn compatible(&self, other: &(dyn Isolation + 'static)) -> 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.

fn join(&self, other: &(dyn Isolation + 'static)) -> 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§

§

impl dyn Isolation

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

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

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

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.

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

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.

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

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

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

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

Implementors§

§

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