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

Replace manual Clone impl with educe in arti-hyper

parent ea03cc40
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@ version = "0.1.0"
dependencies = [
 "anyhow",
 "arti-client",
 "educe",
 "hyper",
 "pin-project",
 "thiserror",
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ experimental-api = []
[dependencies]
anyhow = "1.0.23"
arti-client = { path="../arti-client", version = "0.1.0"}
educe = "0.4.6"
hyper = { version = "0.14", features = ["http1", "client", "runtime"] }
pin-project = "1"
tokio = { package = "tokio", version = "1.7", features = ["rt", "rt-multi-thread", "io-util", "net", "time", "macros" ] }
+3 −7
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ use std::sync::Arc;
use std::task::{Context, Poll};

use arti_client::{DataStream, IntoTorAddr, TorClient};
use educe::Educe;
use hyper::client::connect::{Connected, Connection};
use hyper::http::uri::Scheme;
use hyper::http::Uri;
@@ -111,6 +112,8 @@ impl tor_error::HasKind for ConnectionError {
/// This is a different Rust type to the TLS used *by* Tor to connect to relays etc.
/// It might even be a different underlying TLS implementation
/// (although that is usually not a particularly good idea).
#[derive(Educe)]
#[educe(Clone)] // #[derive(Debug)] infers an unwanted bound TC: Clone
pub struct ArtiHttpConnector<R: Runtime, TC: TlsConn> {
    /// The client
    client: TorClient<R>,
@@ -120,13 +123,6 @@ pub struct ArtiHttpConnector<R: Runtime, TC: TlsConn> {
}

// #[derive(Clone)] infers a TC: Clone bound
impl<R: Runtime, TC: TlsConn> Clone for ArtiHttpConnector<R, TC> {
    fn clone(&self) -> Self {
        let client = self.client.clone();
        let tls_conn = self.tls_conn.clone();
        Self { client, tls_conn }
    }
}

impl<R: Runtime, TC: TlsConn> ArtiHttpConnector<R, TC> {
    /// Make a new `ArtiHttpConnector` using an Arti `TorClient` object.