Skip to content

Commit 868ffd2

Browse files
committed
src: remove Clone from HttpClient impls
1 parent 9ccba5c commit 868ffd2

File tree

4 files changed

+8
-42
lines changed

4 files changed

+8
-42
lines changed

src/h1.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ impl H1Client {
2222
}
2323
}
2424

25-
impl Clone for H1Client {
26-
fn clone(&self) -> Self {
27-
Self {}
28-
}
29-
}
30-
3125
#[async_trait]
3226
impl HttpClient for H1Client {
3327
async fn send(&self, mut req: Request) -> Result<Response, Error> {

src/hyper.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::convert::TryFrom;
1111
use std::fmt::Debug;
1212
use std::io;
1313
use std::str::FromStr;
14-
use std::sync::Arc;
1514

1615
type HyperRequest = hyper::Request<hyper::Body>;
1716

@@ -28,28 +27,22 @@ impl<C: Clone + Connect + Debug + Send + Sync + 'static> HyperClientObject for h
2827

2928
/// Hyper-based HTTP Client.
3029
#[derive(Debug)]
31-
pub struct HyperClient(Arc<dyn HyperClientObject>);
30+
pub struct HyperClient(Box<dyn HyperClientObject>);
3231

3332
impl HyperClient {
3433
/// Create a new client instance.
3534
pub fn new() -> Self {
3635
let https = HttpsConnector::new();
3736
let client = hyper::Client::builder().build(https);
38-
Self(Arc::new(client))
37+
Self::from_client(client)
3938
}
4039

4140
/// Create from externally initialized and configured client.
4241
pub fn from_client<C>(client: hyper::Client<C>) -> Self
4342
where
4443
C: Clone + Connect + Debug + Send + Sync + 'static,
4544
{
46-
Self(Arc::new(client))
47-
}
48-
}
49-
50-
impl Clone for HyperClient {
51-
fn clone(&self) -> Self {
52-
Self(self.0.clone())
45+
Self(Box::new(client))
5346
}
5447
}
5548

src/isahc.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ use super::{async_trait, Body, Error, HttpClient, Request, Response};
44

55
use async_std::io::BufReader;
66
use isahc::http;
7-
use std::sync::Arc;
87

98
/// Curl-based HTTP Client.
109
#[derive(Debug)]
11-
pub struct IsahcClient {
12-
client: Arc<isahc::HttpClient>,
13-
}
10+
pub struct IsahcClient(isahc::HttpClient);
1411

1512
impl Default for IsahcClient {
1613
fn default() -> Self {
@@ -26,17 +23,7 @@ impl IsahcClient {
2623

2724
/// Create from externally initialized and configured client.
2825
pub fn from_client(client: isahc::HttpClient) -> Self {
29-
Self {
30-
client: Arc::new(client),
31-
}
32-
}
33-
}
34-
35-
impl Clone for IsahcClient {
36-
fn clone(&self) -> Self {
37-
Self {
38-
client: self.client.clone(),
39-
}
26+
Self(client)
4027
}
4128
}
4229

@@ -59,7 +46,7 @@ impl HttpClient for IsahcClient {
5946
};
6047

6148
let request = builder.body(body).unwrap();
62-
let res = self.client.send_async(request).await.map_err(Error::from)?;
49+
let res = self.0.send_async(request).await.map_err(Error::from)?;
6350
let (parts, body) = res.into_parts();
6451
let len = body.len().map(|len| len as usize);
6552
let body = Body::from_reader(BufReader::new(body), len);

src/wasm.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,12 @@ use std::task::{Context, Poll};
1010

1111
/// WebAssembly HTTP Client.
1212
#[derive(Debug)]
13-
pub struct WasmClient {
14-
_priv: (),
15-
}
13+
pub struct WasmClient {}
1614

1715
impl WasmClient {
1816
/// Create a new instance.
1917
pub fn new() -> Self {
20-
Self { _priv: () }
21-
}
22-
}
23-
24-
impl Clone for WasmClient {
25-
fn clone(&self) -> Self {
26-
Self { _priv: () }
18+
Self {}
2719
}
2820
}
2921

0 commit comments

Comments
 (0)