[−][src]Struct reqwest::Body
The body of a Request.
In most cases, this is not needed directly, as the
RequestBuilder.body method uses Into<Body>, which allows
passing many things (like a string or vector of bytes).
Methods
impl Body[src]
pub fn new<R: Read + Send + 'static>(reader: R) -> Body[src]
Instantiate a Body from a reader.
Note
While allowing for many types to be used, these bodies do not have
a way to reset to the beginning and be reused. This means that when
encountering a 307 or 308 status code, instead of repeating the
request at the new location, the Response will be returned with
the redirect status code set.
let file = File::open("national_secrets.txt")?; let body = Body::new(file);
If you have a set of bytes, like String or Vec<u8>, using the
From implementations for Body will store the data in a manner
it can be reused.
let s = "A stringy body"; let body = Body::from(s);
pub fn sized<R: Read + Send + 'static>(reader: R, len: u64) -> Body[src]
Create a Body from a Read where the size is known in advance
but the data should not be fully loaded into memory. This will
set the Content-Length header and stream from the Read.
let file = File::open("a_large_file.txt")?; let file_size = file.metadata()?.len(); let body = Body::sized(file, file_size);
Trait Implementations
impl From<Vec<u8>> for Body[src]
impl From<String> for Body[src]
impl From<&'static [u8]> for Body[src]
impl From<&'static str> for Body[src]
impl From<File> for Body[src]
impl Debug for Body[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>, [src]
T: From<U>,
type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,