mehcode/shio-rs

Allow Conversion between shio::request::Body and hyper::Body

Opened this issue · 1 comments

This may already be handled in another way, but I can't for the life of me work it out.

Using the HTTP Stream example, say you wanted to convert this into a POST request and include the body.

You'd do something like this:

    let mut client_req = Request::new(ctx.method().clone(), "http://example.com".parse().unwrap());
    client_req.headers_mut().extend(ctx.headers().iter());
    client_req.set_body(ctx.body());

Only the issue is that you can't convert shio::request::Body to hyper::Body:

error[E0277]: the trait bound `hyper::Body: std::convert::From<shio::request::Body>` is not satisfied
  --> src/main.rs:17:16
   |
17 |     client_req.set_body(ctx.body());
   |                ^^^^^^^^ the trait `std::convert::From<shio::request::Body>` is not implemented for `hyper::Body`

Looks like there has been some restructuring of the body in the latest version. I've submitted a PR.