Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I tried, but it doesn't work #2

Open
Xuanwo opened this issue Aug 30, 2024 · 1 comment
Open

I tried, but it doesn't work #2

Xuanwo opened this issue Aug 30, 2024 · 1 comment

Comments

@Xuanwo
Copy link
Owner

Xuanwo commented Aug 30, 2024

I plan to build something like:

pub trait HttpSend<RequestBody>
where
    RequestBody: Body + 'static,
{
    type ResponseBody: Body + 'static;
    type Error: std::error::Error;

    fn send(
        &self,
        req: Request<RequestBody>,
    ) -> impl Future<Output = Result<Response<Self::ResponseBody>, Self::Error>> + Send;
}

But it failed for the very first step: reqwest:

impl<RequestBody> HttpSend<RequestBody> for Sender
where
    RequestBody: http_body::Body + 'static,
{
    type ResponseBody = reqwest::Body;
    type Error = reqwest::Error;

    async fn send(
        &self,
        req: http::Request<RequestBody>,
    ) -> Result<http::Response<Self::ResponseBody>, Self::Error> {
        // No way to convert `http_body::Body` into `reqwest::Body`
        Ok(self.0.execute(req.try_into()?).await?.into())
    }
}

We need seanmonstar/reqwest#2243

@Xuanwo
Copy link
Owner Author

Xuanwo commented Sep 4, 2024

seanmonstar/reqwest#2255 merged, let's move!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant