pub struct ResponseStream { /* private fields */ }Expand description
A streamed response body (issue #585).
Answering with one bridges the chunks to the wire without buffering them:
on native (and in the test kit) the axum body is polled directly, so
nothing runtime-specific is needed. A runtime that cannot bridge an axum
body — runtime-cloudflare — instead calls ResponseStream::take to
pull the stream out of the response extensions. Whoever takes first wins;
the other side then sees an empty body.
Implementations§
Source§impl ResponseStream
impl ResponseStream
Sourcepub fn new<S, O, E>(stream: S) -> Self
pub fn new<S, O, E>(stream: S) -> Self
Wraps stream as a response body. No ceiling: a streamed response is
bounded by the handler that produced it, not by a request limit.
Sourcepub fn take(&self) -> Option<BoxStream<'static, Result<Bytes, StreamError>>>
pub fn take(&self) -> Option<BoxStream<'static, Result<Bytes, StreamError>>>
Takes the underlying stream, for a runtime that bridges it to its own
response type rather than polling the axum body — runtime-cloudflare
builds a Worker response from it, because converting an axum body into
a Worker Response hangs the isolate. None once the body has
already been polled (or taken).
§Panics
Panics if the slot’s lock is poisoned — only reachable if a prior poll panicked while holding it.
Trait Implementations§
Source§impl Clone for ResponseStream
impl Clone for ResponseStream
Source§impl IntoResponse for ResponseStream
impl IntoResponse for ResponseStream
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl Freeze for ResponseStream
impl RefUnwindSafe for ResponseStream
impl Send for ResponseStream
impl Sync for ResponseStream
impl Unpin for ResponseStream
impl UnsafeUnpin for ResponseStream
impl UnwindSafe for ResponseStream
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, S> Handler<IntoResponseHandler, S> for T
impl<T, S> Handler<IntoResponseHandler, S> for T
Source§fn call(
self,
_req: Request<Body>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S>>::Future
fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future
Source§fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
tower::Layer to the handler. Read moreSource§fn with_state(self, state: S) -> HandlerService<Self, T, S>
fn with_state(self, state: S) -> HandlerService<Self, T, S>
Service by providing the stateSource§impl<H, T> HandlerWithoutStateExt<T> for H
impl<H, T> HandlerWithoutStateExt<T> for H
Source§fn into_service(self) -> HandlerService<H, T, ()>
fn into_service(self) -> HandlerService<H, T, ()>
Service and no state.Source§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
MakeService and no state. Read more