mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Make simple_request::Client generic to the executor
Part of https://github.com/serai-dex/serai/issues/682. We don't remove the use of `tokio::sync::Mutex` now as `hyper` pulls in `tokio::sync` anyways, so there's no point in replacing it. This doesn't yet solve TLS for non-`tokio` `Client`s.
This commit is contained in:
@@ -1,23 +1,22 @@
|
||||
[package]
|
||||
name = "simple-request"
|
||||
version = "0.1.99"
|
||||
version = "0.2.99"
|
||||
description = "simple-request which patches to the latest update"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/patches/simple-request"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = ["nostd", "no_std", "alloc", "io"]
|
||||
edition = "2021"
|
||||
rust-version = "1.65"
|
||||
rust-version = "1.71"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
simple-request = { path = "../../common/request" }
|
||||
hyper-util = { version = "0.1", default-features = false, features = ["tokio"] }
|
||||
simple-request = { path = "../../common/request", default-features = false, features = ["tokio"] }
|
||||
|
||||
[features]
|
||||
tls = ["simple-request/tls"]
|
||||
basic-auth = ["simple-request/basic-auth"]
|
||||
|
||||
@@ -1,18 +1,2 @@
|
||||
pub use simple_request::{hyper, Error, Request, Response};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Client(simple_request::Client);
|
||||
|
||||
impl Client {
|
||||
pub fn with_connection_pool() -> Client {
|
||||
Self(simple_request::Client::with_connection_pool().unwrap())
|
||||
}
|
||||
|
||||
pub fn without_connection_pool(host: &str) -> Result<Client, Error> {
|
||||
simple_request::Client::without_connection_pool(host).map(Self)
|
||||
}
|
||||
|
||||
pub async fn request<R: Into<Request>>(&self, request: R) -> Result<Response<'_>, Error> {
|
||||
self.0.request(request).await
|
||||
}
|
||||
}
|
||||
pub use simple_request::{hyper, Error, Request, TokioClient as Client};
|
||||
pub type Response<'a> = simple_request::Response<'a, hyper_util::rt::tokio::TokioExecutor>;
|
||||
|
||||
Reference in New Issue
Block a user