Skip to content

Commit 6409e37

Browse files
authored
Merge pull request #48 from Fishrock123/no-clone
No Clone for HttpClient-s
2 parents 3cfd120 + d9d7e33 commit 6409e37

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

src/h1.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use http_types::StatusCode;
77

88
/// Async-h1 based HTTP Client.
99
#[derive(Debug)]
10-
pub struct H1Client {}
10+
pub struct H1Client {
11+
_priv: (),
12+
}
1113

1214
impl Default for H1Client {
1315
fn default() -> Self {
@@ -18,13 +20,7 @@ impl Default for H1Client {
1820
impl H1Client {
1921
/// Create a new instance.
2022
pub fn new() -> Self {
21-
Self {}
22-
}
23-
}
24-
25-
impl Clone for H1Client {
26-
fn clone(&self) -> Self {
27-
Self {}
23+
Self { _priv: () }
2824
}
2925
}
3026

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: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ impl WasmClient {
2121
}
2222
}
2323

24-
impl Clone for WasmClient {
25-
fn clone(&self) -> Self {
26-
Self { _priv: () }
27-
}
28-
}
29-
3024
impl HttpClient for WasmClient {
3125
fn send<'a, 'async_trait>(
3226
&'a self,

0 commit comments

Comments
 (0)