Struct Body
pub struct Body { /* private fields */ }
An asynchronous request body.
Implementations
impl Body
fn as_bytes(&self) -> Option<&[u8]>Returns a reference to the internal data of the
Body.Noneis returned, if the underlying data is a stream.fn wrap_stream<S>(stream: S) -> Body where S: TryStream + Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync>>, Bytes: From<S::Ok>,Wrap a futures
Streamin a box insideBody.Example
# use reqwest::Body; # use futures_util; # fn main() { let chunks: Vec<Result<_, ::std::io::Error>> = vec![ Ok("hello"), Ok(" "), Ok("world"), ]; let stream = futures_util::stream::iter(chunks); let body = Body::wrap_stream(stream); # }Optional
This requires the
streamfeature to be enabled.fn wrap<B>(inner: B) -> Body where B: HttpBody + Send + Sync + 'static, B::Data: Into<Bytes>, B::Error: Into<Box<dyn Error + Send + Sync>>,Wrap a
HttpBodyin a box insideBody.Example
# use reqwest::Body; # use futures_util; # fn main() { let content = "hello,world!".to_string(); let body = Body::wrap(content); # }
Trait Implementations
impl Body for Body
type Data = Bytes;type Error = Error;fn poll_frame(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>>fn size_hint(&self) -> SizeHintfn is_end_stream(&self) -> bool
impl Debug for Body
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for Body
fn default() -> Body
impl From<&'static [u8]> for Body
fn from(s: &'static [u8]) -> Body
impl From<&'static str> for Body
fn from(s: &'static str) -> Body
impl From<Bytes> for Body
fn from(bytes: Bytes) -> Body
impl From<File> for Body
fn from(file: File) -> Body
impl From<Response> for Body
fn from(r: Response) -> Body
impl From<String> for Body
fn from(s: String) -> Body
impl From<Vec<u8>> for Body
fn from(vec: Vec<u8>) -> Body