Commit 3eed75a5 authored by Niel Duysters's avatar Niel Duysters Committed by wesleyac
Browse files

arti-ureq: Move `builder()` and `new()` to non-generic PreferredRuntime impl

`builder()` and `new()` always return a runtime with `tor_rtcompat::PreferredRuntime` so these methods should only be implemented for that type.
parent 4a096515
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -374,16 +374,18 @@ impl<R: Runtime + ToplevelBlockOn> Transport for HttpTransport<R> {
    }
}

impl<R: Runtime> ConnectorBuilder<R> {
impl ConnectorBuilder<tor_rtcompat::PreferredRuntime> {
    /// Returns instance of [`ConnectorBuilder`] with default values.
    pub fn new() -> Result<ConnectorBuilder<tor_rtcompat::PreferredRuntime>, Error> {
    pub fn new() -> Result<Self, Error> {
        Ok(ConnectorBuilder {
            client: None,
            runtime: tor_rtcompat::PreferredRuntime::create()?,
            tls_provider: None,
        })
    }
}

impl<R: Runtime> ConnectorBuilder<R> {
    /// Creates instance of [`Connector`] from the builder.
    pub fn build(self) -> Result<Connector<R>, Error> {
        let client = match self.client {
@@ -628,10 +630,10 @@ pub fn get_default_tls_provider() -> UreqTlsProvider {
///
/// let arti_connector = builder.build();
/// ```
impl<R: Runtime> Connector<R> {
impl Connector<tor_rtcompat::PreferredRuntime> {
    /// Returns new [`ConnectorBuilder`] with default values.
    pub fn builder() -> Result<ConnectorBuilder<tor_rtcompat::PreferredRuntime>, Error> {
        ConnectorBuilder::<R>::new()
        ConnectorBuilder::new()
    }
}