Skip to content

Commit 313f13b

Browse files
committed
Avoid hyper-util types in public API
1 parent 895cb2f commit 313f13b

File tree

4 files changed

+15
-22
lines changed

4 files changed

+15
-22
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ allowed_external_types = [
7676
"http_body::*",
7777
"http_body_util::*",
7878
"hyper::*",
79-
"hyper_util::*",
8079
"rustls_pki_types::*",
8180
"serde::*",
8281
"serde_json::*",

src/account.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,7 @@ impl Signer for Key {
578578
}
579579

580580
fn sign(&self, payload: &[u8]) -> Result<Self::Signature, Error> {
581-
self
582-
.inner
581+
self.inner
583582
.sign(&self.rng, payload)
584583
.map_err(|_| Error::Crypto)
585584
}

src/lib.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use http::{Method, Request, Response, StatusCode};
1818
use http_body_util::{BodyExt, Full};
1919
use httpdate::HttpDate;
2020
#[cfg(feature = "hyper-rustls")]
21+
use hyper::body::Incoming;
22+
#[cfg(feature = "hyper-rustls")]
2123
use hyper_util::client::legacy::Client as HyperClient;
2224
#[cfg(feature = "hyper-rustls")]
2325
use hyper_util::client::legacy::connect::{Connect, HttpConnector};
@@ -211,12 +213,7 @@ impl HttpClient for DefaultClient {
211213
req: Request<Full<Bytes>>,
212214
) -> Pin<Box<dyn Future<Output = Result<BytesResponse, Error>> + Send>> {
213215
let fut = self.0.request(req);
214-
Box::pin(async move {
215-
match fut.await {
216-
Ok(rsp) => Ok(BytesResponse::from(rsp)),
217-
Err(e) => Err(e.into()),
218-
}
219-
})
216+
Box::pin(async move { BytesResponse::try_from(fut.await) })
220217
}
221218
}
222219

@@ -236,12 +233,7 @@ impl<C: Connect + Clone + Send + Sync + 'static> HttpClient for HyperClient<C, F
236233
req: Request<Full<Bytes>>,
237234
) -> Pin<Box<dyn Future<Output = Result<BytesResponse, Error>> + Send>> {
238235
let fut = self.request(req);
239-
Box::pin(async move {
240-
match fut.await {
241-
Ok(rsp) => Ok(BytesResponse::from(rsp)),
242-
Err(e) => Err(e.into()),
243-
}
244-
})
236+
Box::pin(async move { BytesResponse::try_from(fut.await) })
245237
}
246238
}
247239

@@ -254,6 +246,16 @@ pub struct BytesResponse {
254246
}
255247

256248
impl BytesResponse {
249+
#[cfg(feature = "hyper-rustls")]
250+
fn try_from(
251+
result: Result<Response<Incoming>, hyper_util::client::legacy::Error>,
252+
) -> Result<Self, Error> {
253+
match result {
254+
Ok(rsp) => Ok(BytesResponse::from(rsp)),
255+
Err(e) => Err(Error::Other(Box::new(e))),
256+
}
257+
}
258+
257259
pub(crate) async fn body(mut self) -> Result<Bytes, Box<dyn StdError + Send + Sync + 'static>> {
258260
self.body.into_bytes().await
259261
}

src/types.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@ impl From<&'static str> for Error {
7878
}
7979
}
8080

81-
#[cfg(feature = "hyper-rustls")]
82-
impl From<hyper_util::client::legacy::Error> for Error {
83-
fn from(value: hyper_util::client::legacy::Error) -> Self {
84-
Self::Other(Box::new(value))
85-
}
86-
}
87-
8881
/// ACME account credentials
8982
///
9083
/// This opaque type contains the account ID, the private key data and the

0 commit comments

Comments
 (0)