pub struct StreamingBody { /* private fields */ }Expand description
Typed streaming HTTP response body.
exact_length is optional. HTTP/1 uses chunked transfer coding when it is
absent, while HTTP/2 emits DATA frames without a content-length field.
Implementations§
Source§impl StreamingBody
impl StreamingBody
pub fn new(stream: impl BodyStream) -> Self
Sourcepub fn from_chunks<I, Chunk>(chunks: I) -> Self
pub fn from_chunks<I, Chunk>(chunks: I) -> Self
Builds a pull stream from already available chunks.
Sourcepub fn once(bytes: impl Into<Vec<u8>>) -> Self
pub fn once(bytes: impl Into<Vec<u8>>) -> Self
Builds a one-chunk stream with a known exact length.
pub const fn with_exact_length(self, length: u64) -> Self
pub const fn exact_length(&self) -> Option<u64>
Sourcepub async fn next_chunk(&mut self) -> Option<Result<Vec<u8>, BodyStreamError>>
pub async fn next_chunk(&mut self) -> Option<Result<Vec<u8>, BodyStreamError>>
Waits until the producer yields one chunk.
Calling this method is the consumer demand signal. Transports should not request another chunk until the previous one has been written.
Sourcepub fn recycle(&mut self, spent: Vec<u8>)
pub fn recycle(&mut self, spent: Vec<u8>)
Hands a spent chunk’s buffer back to the producer for reuse.
See BodyStream::recycle; producers that do not reuse buffers
simply drop it.
Trait Implementations§
Source§impl ApiSchema for StreamingBody
impl ApiSchema for StreamingBody
fn type_descriptor() -> TypeDescriptor
Source§fn validate_input(&self) -> Result<(), ValidationErrors>
fn validate_input(&self) -> Result<(), ValidationErrors>
Validates a decoded operation argument. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for StreamingBody
impl !Send for StreamingBody
impl !Sync for StreamingBody
impl !UnwindSafe for StreamingBody
impl Freeze for StreamingBody
impl Unpin for StreamingBody
impl UnsafeUnpin for StreamingBody
Blanket Implementations§
Source§impl<T> BackgroundExt for T
impl<T> BackgroundExt for T
fn background(self, task: BackgroundTask) -> Background<Self>
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