pub struct BodyReader { /* private fields */ }Expand description
Consumer end — stored in the reader registry.
Uses tokio::sync::Mutex so we can .await the receiver without holding
the registry’s std::sync::Mutex.
Per ADR-014 D4 this type implements http_body::Body directly so it can
be wrapped into crate::Body without an intermediate StreamBody
adapter. The two consumer paths are disjoint:
- Internal hyper path — the
Bodyimpl drivespoll_frame. TheBodyReaderis moved intocrate::Body::newand never registered in the FFI handle store. - FFI path — JS calls
next_chunk(handle)viaHandleStore; theBodyimpl is never polled.
Implementations§
Source§impl BodyReader
impl BodyReader
Sourcepub async fn next_chunk(&self) -> Option<Bytes>
pub async fn next_chunk(&self) -> Option<Bytes>
Receive the next chunk. Returns None when the writer is gone (EOF)
or when the reader has been cancelled.
Trait Implementations§
Source§impl Body for BodyReader
ADR-014 D4: BodyReader is itself an http_body::Body so callers can
wrap it in crate::Body::new without a StreamBody/unfold adapter.
impl Body for BodyReader
ADR-014 D4: BodyReader is itself an http_body::Body so callers can
wrap it in crate::Body::new without a StreamBody/unfold adapter.
Source§type Error = Infallible
type Error = Infallible
The error type this
Body might generate.Source§fn poll_frame(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Frame<Bytes>, Self::Error>>>
fn poll_frame( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Frame<Bytes>, Self::Error>>>
Attempt to pull out the next data buffer of this stream.
Source§fn is_end_stream(&self) -> bool
fn is_end_stream(&self) -> bool
Returns
true when the end of stream has been reached. Read moreAuto Trait Implementations§
impl Freeze for BodyReader
impl !RefUnwindSafe for BodyReader
impl Send for BodyReader
impl Sync for BodyReader
impl Unpin for BodyReader
impl UnsafeUnpin for BodyReader
impl !UnwindSafe for BodyReader
Blanket Implementations§
Source§impl<T> BodyExt for T
impl<T> BodyExt for T
Source§fn frame(&mut self) -> Frame<'_, Self>where
Self: Unpin,
fn frame(&mut self) -> Frame<'_, Self>where
Self: Unpin,
Returns a future that resolves to the next
Frame, if any.Source§fn map_frame<F, B>(self, f: F) -> MapFrame<Self, F>
fn map_frame<F, B>(self, f: F) -> MapFrame<Self, F>
Maps this body’s frame to a different kind.
Source§fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
Maps this body’s error value to a different value.
Source§fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
Turn this body into a boxed trait object that is !Sync.
Source§fn collect(self) -> Collect<Self>where
Self: Sized,
fn collect(self) -> Collect<Self>where
Self: Sized,
Turn this body into
Collected body which will collect all the DATA frames
and trailers.Source§fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
Add trailers to the body. Read more
Source§fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
Turn this body into
BodyDataStream.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
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