Feature: Implement the Body trait for more native data types to improve ergonomics
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.3k
- Forks
- 1.8k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 14
Description
Currently, the 'String' is the only native data type that implements hyper::body::Body.
If we're passing other data types as a body, we need to add the http_body_util crate and add a little bit of boiler plate when building our request.
use http_body_util::Full;
let some_bytes = vec![0_u8, 1, 2];
let mut req = Request::builder()
.method("POST")
.body(Full::<Bytes>::from(some_bytes))
.unwrap();
Note: While the request builder itself may not require the body to implement the Body trait, both the sender and connection returned by http1::handshake require the request's body to implement it.
With the body trait implemented for Vec<u8> (just one example that probably should implement body) we could leave out the http_body_util crate. Building a request would also become more intuitive and ergonomic.
let some_bytes = vec![0_u8, 1, 2];
let mut req = Request::builder()
.method("POST")
.body(some_bytes)
.unwrap();
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the hyper::body::Body trait and the request path through http1::handshake, including the sender and connection requirements described in the issue. Confirm which native types are in scope beyond Vec<u8> and define completion around sending requests with those types without http_body_util; the issue does not name files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100