pub struct UploadWriter { /* private fields */ }Expand description
The writing end of a streamed UploadBody, from
UploadBody::channel.
The writer and the upload run together. So a caller writes from a task
other than the task that awaits Fetcher::upload, or joins the two
futures.
§Frames
Writes fill a frame of 64 KiB. The writer gives a full frame to the connection through a slot of one frame. If the slot is still full, a write waits until hyper takes the frame in it.
flushhands over a part-filled frame, and waits until hyper takes it.closehands over the rest, ends the body, and waits until hyper takes the end.
A flush of less than 4 KiB hands over a copy of the bytes and keeps the frame buffer. A larger frame moves to the connection as it is, and the next write allocates the next buffer.
§Memory
The writer holds at most two frames: the frame that it fills and the frame in the slot. The connection holds more for each upload in flight.
Over HTTP/1.1, hyper takes another frame while it holds fewer than 16 frames and less than 408 KiB. So it holds up to 472 KiB. Over HTTP/2, it holds up to two frames.
§Stalls
After the upload hands its request to the connection, a frame can wait in
the slot for the progress_timeout of
its fetcher. If it does, the wait fails with
io::ErrorKind::TimedOut, and the body
fails. Before the hand-over, a wait has no bound of its own.
§Failures
If the writer is dropped before close, the body fails. So hyper ends the request unfinished, and the server never receives a truncated body as a whole body. A writer dropped before the hand-over leaves the request unsent.
A write fails with
io::ErrorKind::BrokenPipe in these
cases:
- after close
- after the upload is done with the body
- after the response ended before the body.
A failure is latched: each later call fails in the same way.
Implementations§
Source§impl UploadWriter
impl UploadWriter
Sourcepub fn is_handed_over(&self) -> bool
pub fn is_handed_over(&self) -> bool
Returns true if the request of this body is handed over to a
connection.
The value becomes true at the hand-over. It becomes false again if
the connection gives the request back unwritten, until the next round
hands it over. A caller that counts the bytes that a request sent counts
the bytes that it wrote after the hand-over.
Trait Implementations§
Source§impl AsyncWrite for UploadWriter
The write trait of futures-io.
impl AsyncWrite for UploadWriter
The write trait of futures-io.
Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
buf into the object. Read moreSource§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Source§impl Debug for UploadWriter
impl Debug for UploadWriter
Source§impl Drop for UploadWriter
impl Drop for UploadWriter
Auto Trait Implementations§
impl Freeze for UploadWriter
impl RefUnwindSafe for UploadWriter
impl Send for UploadWriter
impl Sync for UploadWriter
impl Unpin for UploadWriter
impl UnsafeUnpin for UploadWriter
impl UnwindSafe for UploadWriter
Blanket Implementations§
Source§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
Source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self> ⓘwhere
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self> ⓘwhere
Self: Unpin,
Source§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectoredFuture<'a, Self> ⓘwhere
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectoredFuture<'a, Self> ⓘwhere
Self: Unpin,
Source§fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self> ⓘwhere
Self: Unpin,
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self> ⓘwhere
Self: Unpin,
Source§fn flush(&mut self) -> FlushFuture<'_, Self> ⓘwhere
Self: Unpin,
fn flush(&mut self) -> FlushFuture<'_, Self> ⓘwhere
Self: Unpin,
Source§fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a>>
fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a>>
alloc only.dyn AsyncWrite + Send + 'a. Read more