StreamingBody
pub struct StreamingBody { /* private fields */ }A streaming HTTP body that can be written to, or appended to from another body.
The interface to this type is very similar to Body, however it is write-only, and can only be
created as a result of calling
Response::stream_to_client() or
Request::send_async_streaming(),
or as part of a CandidateResponse body transformation.
The most efficient way to write the body is through the Write implementation. Writes are
buffered, and automatically flushed, but you can call Write::flush() to explicitly flush the
buffer and cause a new chunk to be written to the client.
A streaming body will be automatically aborted if it goes out of scope without calling
finish().
Methods
abandon
View sourceAbandon a streaming body handle, indicating an unsuccessful end of the stream.
Parameters
- self: Self
Returns
append
View sourceAppend a body onto the end of this streaming body.
This operation is performed in amortized constant time, and so should always be preferred to reading an entire body and then writing the same contents to another body.
Examples
let mut streaming_body = beresp.stream_to_client();streaming_body.append(other_body);Parameters
- self: &mut Self
- other: Body
finish
View sourceFinish writing to a streaming body handle.
Parameters
- self: Self
Returns
Trait implementations
impl From<StreamingBodyHandle> for StreamingBody
impl StreamingBodyExt for StreamingBody
impl Write for StreamingBody
write_vectored
View sourceParameters
- self: &mut Self
- bufs: &[std::io::IoSlice]
Returns