Struct tor_circmgr::isolation::IsolationToken
source · pub struct IsolationToken(_);Expand description
A token used to isolate unrelated streams on different circuits.
When two streams are associated with different isolation tokens, they can never share the same circuit.
Tokens created with IsolationToken::new are all different from
one another, and different from tokens created with
IsolationToken::no_isolation. However, tokens created with
IsolationToken::no_isolation are all equal to one another.
Examples
Creating distinct isolation tokens:
let token_1 = IsolationToken::new();
let token_2 = IsolationToken::new();
assert_ne!(token_1, token_2);
// Demonstrating the behaviour of no_isolation() tokens:
assert_ne!(token_1, IsolationToken::no_isolation());
assert_eq!(IsolationToken::no_isolation(), IsolationToken::no_isolation());Using an isolation token to route streams differently over the Tor network:
use arti_client::StreamPrefs;
let token_1 = IsolationToken::new();
let token_2 = IsolationToken::new();
let mut prefs_1 = StreamPrefs::new();
prefs_1.set_isolation(token_1);
let mut prefs_2 = StreamPrefs::new();
prefs_2.set_isolation(token_2);
// These two connections will come from different source IP addresses.
tor_client.connect(("example.com", 80), Some(prefs_1)).await?;
tor_client.connect(("example.com", 80), Some(prefs_2)).await?;Implementations§
source§impl IsolationToken
impl IsolationToken
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new IsolationToken, unequal to any other token this function has created.
Panics
Panics if we have already allocated 2^64 isolation tokens: in that case, we have exhausted the space of possible tokens, and it is no longer possible to ensure isolation.
sourcepub fn no_isolation() -> Self
pub fn no_isolation() -> Self
Create a new IsolationToken equal to every other token created
with this function, but different from all tokens created with
new.
This can be used when no isolation is wanted for some streams.
Trait Implementations§
source§impl Clone for IsolationToken
impl Clone for IsolationToken
source§fn clone(&self) -> IsolationToken
fn clone(&self) -> IsolationToken
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for IsolationToken
impl Debug for IsolationToken
source§impl IsolationHelper for IsolationToken
impl IsolationHelper for IsolationToken
source§impl Ord for IsolationToken
impl Ord for IsolationToken
source§fn cmp(&self, other: &IsolationToken) -> Ordering
fn cmp(&self, other: &IsolationToken) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<IsolationToken> for IsolationToken
impl PartialEq<IsolationToken> for IsolationToken
source§fn eq(&self, other: &IsolationToken) -> bool
fn eq(&self, other: &IsolationToken) -> bool
source§impl PartialOrd<IsolationToken> for IsolationToken
impl PartialOrd<IsolationToken> for IsolationToken
source§fn partial_cmp(&self, other: &IsolationToken) -> Option<Ordering>
fn partial_cmp(&self, other: &IsolationToken) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Copy for IsolationToken
impl Eq for IsolationToken
impl StructuralEq for IsolationToken
impl StructuralPartialEq for IsolationToken
Auto Trait Implementations§
impl RefUnwindSafe for IsolationToken
impl Send for IsolationToken
impl Sync for IsolationToken
impl Unpin for IsolationToken
impl UnwindSafe for IsolationToken
Blanket Implementations§
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read moresource§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read moresource§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read moresource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read more