You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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];letmut 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];letmut req = Request::builder().method("POST").body(some_bytes).unwrap();
Some think that this would make this functionality more intuitive, and save the user from having to import an additional crate, but others prefer the explicitness of using Full.
Please let us know your preference! Your feedback is crucial to making an informed decision that best serves the community!
Should we implement the body trait for more data types (such as `Vec<u8>` and `hyper::body::Bytes`)
Yes, implement the body trait for more native types .
85%
No, don't implement the body trait for any additional data types.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This poll regards the issue #3746.
Issue:
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.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 thehttp_body_util
crate. Building a request would also become more intuitive and ergonomic.Some think that this would make this functionality more intuitive, and save the user from having to import an additional crate, but others prefer the explicitness of using
Full
.Please let us know your preference! Your feedback is crucial to making an informed decision that best serves the community!
7 votes ·
Beta Was this translation helpful? Give feedback.
All reactions