isolation: Provide new_isolation_group method

In the usual case, set_isolation_group is awkward.

This is perhaps slightly duplicative with TorClient::isolated_client().
If so then perhaps the *latter* should be abolished.
This commit is contained in:
Ian Jackson 2022-01-20 12:02:51 +00:00
parent 639db26d58
commit a5356aed65
1 changed files with 14 additions and 0 deletions

View File

@ -197,6 +197,20 @@ impl ConnectPrefs {
self
}
/// Indicate that connections with these preferences should have their own isolation group
///
/// This is a convenience method which creates a fresh [`IsolationToken`]
/// and sets it for these preferences.
///
/// This connection preference is orthogonal to isolation established by
/// [`TorClient::isolated_client`]. Connections made with an `isolated_client` (and its
/// clones) will not share circuits with the original client, even if the same
/// `isolation_group` is specified via the `ConnectionPrefs` in force.
pub fn new_isolation_group(&mut self) -> &mut Self {
self.isolation = StreamIsolationPreference::Explicit(IsolationToken::new());
self
}
/// Return a token to describe which connections might use
/// the same circuit as this one.
fn isolation_group(&self) -> Option<IsolationToken> {