move conversion & rename & tidy

This commit is contained in:
stackinspector 2024-09-01 00:36:55 +08:00
parent 3245712ad3
commit 7bca27f76d
3 changed files with 11 additions and 12 deletions

View File

@ -4,6 +4,12 @@ use hyper_util::client::legacy::connect::Connect;
use hyper_util::client::legacy::Client as HyperClient;
use hyper_util::{client::legacy::connect::HttpConnector, rt::TokioExecutor};
impl From<hyper_util::client::legacy::Error> for Error {
fn from(value: hyper_util::client::legacy::Error) -> Self {
Self::Other(Box::new(value))
}
}
struct DefaultClient(HyperClient<hyper_rustls::HttpsConnector<HttpConnector>, Full<Bytes>>);
impl DefaultClient {
@ -27,7 +33,7 @@ impl HttpClient for DefaultClient {
&self,
req: Request<Full<Bytes>>,
) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, Error>> + Send>> {
Box::pin(_response_future(self.0.request(req)))
Box::pin(handle_response_future(self.0.request(req)))
}
}
@ -36,7 +42,7 @@ impl<C: Connect + Clone + Send + Sync + 'static> HttpClient for HyperClient<C, F
&self,
req: Request<Full<Bytes>>,
) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, Error>> + Send>> {
Box::pin(_response_future(self.request(req)))
Box::pin(handle_response_future(self.request(req)))
}
}

View File

@ -642,7 +642,7 @@ pub trait HttpClient: Send + Sync + 'static {
) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, Error>> + Send>>;
}
async fn _response_future<B: http_body::Body<Error = impl Into<Error>>>(
async fn handle_response_future<B: http_body::Body<Error = impl Into<Error>>>(
fut: impl Future<Output = Result<Response<B>, impl Into<Error>>>,
) -> Result<Response<Bytes>, Error> {
match fut.await {

View File

@ -55,13 +55,6 @@ impl From<&'static str> for Error {
}
}
#[cfg(feature = "hyper-rustls")]
impl From<hyper_util::client::legacy::Error> for Error {
fn from(value: hyper_util::client::legacy::Error) -> Self {
Self::Other(Box::new(value))
}
}
/// ACME account credentials
///
/// This opaque type contains the account ID, the private key data and the