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) -> StreamingBody
Sourcepub fn from_chunks<I, Chunk>(chunks: I) -> StreamingBodywhere
I: IntoIterator<Item = Chunk>,
<I as IntoIterator>::IntoIter: Unpin + 'static,
Chunk: Into<Vec<u8>> + 'static,
pub fn from_chunks<I, Chunk>(chunks: I) -> StreamingBodywhere
I: IntoIterator<Item = Chunk>,
<I as IntoIterator>::IntoIter: Unpin + 'static,
Chunk: Into<Vec<u8>> + 'static,
Builds a pull stream from already available chunks.
Sourcepub fn once(bytes: impl Into<Vec<u8>>) -> StreamingBody
pub fn once(bytes: impl Into<Vec<u8>>) -> StreamingBody
Builds a one-chunk stream with a known exact length.
pub const fn with_exact_length(self, length: u64) -> StreamingBody
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
Source§impl Debug for StreamingBody
impl Debug for StreamingBody
Source§impl OperationOutput for StreamingBody
impl OperationOutput for StreamingBody
fn into_execution_outcome(self) -> ExecutionOutcome
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more