pub enum SendBody<W> {
Raw(W),
ContentLen(ContentLenWrite<W>),
Chunked(ChunkedWrite<W>),
}Expand description
Represents an outgoing HTTP request stream body
Implements the Write trait to write the body to the stream
Variants§
Raw(W)
The body is raw and should be written as is (only possible for HTTP responses with connection = Close)
ContentLen(ContentLenWrite<W>)
The body is of a known length (Content-Length)
Chunked(ChunkedWrite<W>)
The body is chunked (Transfer-Encoding: chunked)
Implementations§
Source§impl<W> SendBody<W>where
W: Write,
impl<W> SendBody<W>where
W: Write,
Sourcepub fn new(body_type: BodyType, output: W) -> SendBody<W>
pub fn new(body_type: BodyType, output: W) -> SendBody<W>
Create a new body
Parameters:
body_type: The type of the body, as resolved usingBodyType::resolveoutput: The raw output stream
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if the body has been completely written to
Sourcepub fn needs_close(&self) -> bool
pub fn needs_close(&self) -> bool
Check if the body needs to be closed (i.e. the underlying output stream cannot be re-used for Keep-Alive connections)
Sourcepub async fn finish(&mut self) -> Result<(), Error<W::Error>>where
W: Write,
pub async fn finish(&mut self) -> Result<(), Error<W::Error>>where
W: Write,
Finish writing the body (necessary for chunked encoding)
Sourcepub fn as_raw_writer(&mut self) -> &mut W
pub fn as_raw_writer(&mut self) -> &mut W
Return a mutable reference to the underlying raw writer
Trait Implementations§
Source§impl<W> Write for SendBody<W>where
W: Write,
impl<W> Write for SendBody<W>where
W: Write,
Source§async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
Write a buffer into this writer, returning how many bytes were written. Read more
Auto Trait Implementations§
impl<W> Freeze for SendBody<W>where
W: Freeze,
impl<W> RefUnwindSafe for SendBody<W>where
W: RefUnwindSafe,
impl<W> Send for SendBody<W>where
W: Send,
impl<W> Sync for SendBody<W>where
W: Sync,
impl<W> Unpin for SendBody<W>where
W: Unpin,
impl<W> UnwindSafe for SendBody<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more