hyper_util: How to add hyper_util::client::pool::map::Map to custom struct?
#3994
|
Is your feature request related to a problem? Please describe. I want use Describe the solution you'd like No idea Additional context I want create a struct of HTTP client like pub struct Client {
...
pub client_pool: hyper_util::client::pool::map::Map<????>,
}But I can't. Is there any alternative? |
Answered by
seanmonstar
Dec 15, 2025
Replies: 1 comment
|
It currently cannot be named, that's correct. What I've done in reqwest, besides also wrapping it as a service, is to convert it into a trait object. Something like this: let map_svc = service_fn(move |req| {
let mut mapped = map.service(req.uri()).call(req.uri());
async move {
let mut svc = mapped.await?;
svc.ready().await?;
svc.call(req).await
}
});
let pool_as_svc = tower::util::BoxService::new(map_svc); |
0 replies
Answer selected by
hatoo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It currently cannot be named, that's correct. What I've done in reqwest, besides also wrapping it as a service, is to convert it into a trait object. Something like this: