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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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