Struct tor_circmgr::IsolationToken [−][src]
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::ConnectPrefs;
let token_1 = IsolationToken::new();
let token_2 = IsolationToken::new();
let mut prefs_1 = ConnectPrefs::new();
prefs_1.set_isolation_group(token_1);
let mut prefs_2 = ConnectPrefs::new();
prefs_2.set_isolation_group(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
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.
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
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
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
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more