Replace manual Clone impl with educe in arti-hyper

This commit is contained in:
Ian Jackson 2022-03-02 14:58:06 +00:00
parent ea03cc4084
commit decdd05ec5
3 changed files with 5 additions and 7 deletions

1
Cargo.lock generated
View File

@ -172,6 +172,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"arti-client",
"educe",
"hyper",
"pin-project",
"thiserror",

View File

@ -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" ] }

View File

@ -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.