Commit ac0ed6ab authored by Ian Jackson's avatar Ian Jackson
Browse files

Replace manual Default impls on enums with educe in arti-client

parent 2a782a71
Loading
Loading
Loading
Loading
+7 −14
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ use tor_proto::circuit::ClientCirc;
use tor_proto::stream::{DataStream, IpVersionPreference, StreamParameters};
use tor_rtcompat::{PreferredRuntime, Runtime, SleepProviderExt};

use educe::Educe;
use futures::lock::Mutex as AsyncMutex;
use futures::stream::StreamExt;
use futures::task::SpawnExt;
@@ -84,11 +85,13 @@ pub struct TorClient<R: Runtime> {
}

/// Preferences for whether a [`TorClient`] should bootstrap on its own or not.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Educe)]
#[educe(Default)]
#[non_exhaustive]
pub enum BootstrapBehavior {
    /// Bootstrap the client automatically when requests are made that require the client to be
    /// bootstrapped.
    #[educe(Default)]
    OnDemand,
    /// Make no attempts to automatically bootstrap. [`TorClient::bootstrap`] must be manually
    /// invoked in order for the [`TorClient`] to become useful.
@@ -99,12 +102,6 @@ pub enum BootstrapBehavior {
    Manual,
}

impl Default for BootstrapBehavior {
    fn default() -> Self {
        BootstrapBehavior::OnDemand
    }
}

/// Preferences for how to route a stream over the Tor network.
#[derive(Debug, Clone, Default)]
pub struct StreamPrefs {
@@ -117,9 +114,11 @@ pub struct StreamPrefs {
}

/// Record of how we are isolating connections
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Educe)]
#[educe(Default)]
enum StreamIsolationPreference {
    /// No additional isolation
    #[educe(Default)]
    None,
    /// Id of the isolation group the connection should be part of
    Explicit(IsolationToken),
@@ -127,12 +126,6 @@ enum StreamIsolationPreference {
    EveryStream,
}

impl Default for StreamIsolationPreference {
    fn default() -> Self {
        StreamIsolationPreference::None
    }
}

impl StreamPrefs {
    /// Construct a new StreamPrefs.
    pub fn new() -> Self {