From a5356aed650a0b5f3fddf2eed06c6f9d65fe49e6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 20 Jan 2022 12:02:51 +0000 Subject: [PATCH] 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. --- crates/arti-client/src/client.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/arti-client/src/client.rs b/crates/arti-client/src/client.rs index 86cc4c2e0..f5b3320d1 100644 --- a/crates/arti-client/src/client.rs +++ b/crates/arti-client/src/client.rs @@ -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 {