pub struct BodyStream { /* private fields */ }Expand description
A request body that is read in pieces, see the module documentation
Implementations§
Source§impl BodyStream
impl BodyStream
Sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Size announced by the client (Content-Length), if any. Untrusted; the
limit is checked against what actually arrives.
Sourcepub fn bytes_read(&self) -> u64
pub fn bytes_read(&self) -> u64
Bytes delivered so far
Sourcepub async fn chunk(&mut self) -> Result<Option<Bytes>>
pub async fn chunk(&mut self) -> Result<Option<Bytes>>
The next piece, or None at the end. Fails with 413 as soon as the
limit is exceeded, and with 400 when the connection breaks mid-body.
Sourcepub async fn copy_to<W: AsyncWrite + Unpin>(
&mut self,
writer: &mut W,
) -> Result<u64>
pub async fn copy_to<W: AsyncWrite + Unpin>( &mut self, writer: &mut W, ) -> Result<u64>
Write the rest of the body to writer; returns the bytes copied
Sourcepub async fn save_to(&mut self, path: impl AsRef<Path>) -> Result<u64>
pub async fn save_to(&mut self, path: impl AsRef<Path>) -> Result<u64>
Write the rest of the body to a file; returns the bytes written
The file is created or replaced. If the body is cut off, too large or the write fails, the partial file is removed. Use a temporary name and rename it afterwards when readers must never see half-written data.
Auto Trait Implementations§
impl !Freeze for BodyStream
impl !RefUnwindSafe for BodyStream
impl !UnwindSafe for BodyStream
impl Send for BodyStream
impl Sync for BodyStream
impl Unpin for BodyStream
impl UnsafeUnpin for BodyStream
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