//! Types for conveniently constructing a TorRelay. use tor_rtcompat::Runtime; use crate::err::Error; use crate::{config::TorRelayConfig, TorRelay}; /// An object for constructing a [`TorRelay`]. /// /// Returned by [`TorRelay::builder()`]. #[derive(Clone)] #[must_use] pub struct TorRelayBuilder { /// The runtime for the client to use runtime: R, /// The configuration. config: TorRelayConfig, } impl TorRelayBuilder { /// Construct a new TorClientBuilder with the given runtime. pub(crate) fn new(runtime: R) -> Self { Self { runtime, config: TorRelayConfig::default(), } } /// Return a newly created TorRelay object. pub fn create(&self) -> Result, Error> { TorRelay::create_inner(self.runtime.clone(), &self.config).map_err(Into::into) } }