Description
I'm trying to port some code to the new hyper to take advantage of async/await, but I'm running into a problem of not being able to wrap a generic hyper::Client. The code I'm working on is yup-oauth2 which accepts an arbitrary hyper::Client from the user and would like to be generic over any connector the user provides.
A distilled form of the problem can be seen here:
async fn make_request<C>(client: &hyper::Client<C>)
where
C: <what can I put here>,
{
println!("{:?}", client.get("http://www.google.com").await.unwrap())
}
We used to bound it by the hyper::client::connect::Connect, but that trait is now sealed making it impossible to reference. I understand that users shouldn't need to implement Connect any longer because of the blanket impl for Service, but by putting it within hidden module it can no longer be referenced by external crates for trait bounds like above. Am I missing a way to write a function like make_request
?
It seems like Connect should be publicly visible, but keep the Sealed trait hidden. That would prevent people from being able to implement it, but still allow the trait to be referenced by users.