pub struct ByteStream { /* private fields */ }Expand description
A raw binary success body read as it arrives, which a binary operation’s _stream twin
returns in place of the whole Bytes its buffered method reads: as the twin’s success, or in
a binary status’s variant of the twin’s success enum.
Self::next yields the body a chunk at a time, and Self::collect_bounded, its only
collector, reads the rest of it into one Bytes within a limit the caller names.
Self::into_body hands the body over as an HttpBody, an http_body::Body, for a reader
of the caller’s own. Dropping it abandons the rest of the body.
On wasm32 too, ReqwestBackend’s fetch response is read chunk by chunk as the browser
delivers it, so a limit stops the read at the chunk that crosses it rather than after the
whole body is in memory.
Implementations§
Source§impl ByteStream
impl ByteStream
Sourcepub async fn next(&mut self) -> Option<Result<Bytes, Error<Infallible>>>
pub async fn next(&mut self) -> Option<Result<Bytes, Error<Infallible>>>
The next chunk of the body, None once it has ended, or the failure that interrupted it.
Sourcepub async fn collect_bounded(
self,
limit: usize,
) -> Result<Bytes, Error<Infallible>>
pub async fn collect_bounded( self, limit: usize, ) -> Result<Bytes, Error<Infallible>>
The rest of the body as one Bytes, or Error::BodyTooLarge once it is known to hold
more than limit bytes: before anything is read, where nothing has been and the response
declared a Content-Length past limit, and otherwise at the chunk that carries it past
limit, which is never buffered. Nothing of an over-limit body is returned. A 1xx, 204
or 304 response, or the answer to a HEAD request, declares no body it carries, so its
Content-Length refuses nothing.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ByteStream
impl !RefUnwindSafe for ByteStream
impl !UnwindSafe for ByteStream
impl Send for ByteStream
impl Sync for ByteStream
impl Unpin for ByteStream
impl UnsafeUnpin for ByteStream
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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