Struct OnIncompleteBody
pub struct OnIncompleteBody<B, F>where
F: FnOnce(),{ /* private fields */ }http and std only.Expand description
A StreamingBody wrapper that calls a closure as soon as it is known
the body will not complete: an error frame is observed, or the body is
dropped before end-of-stream.
Unlike OnDropBody (which only reacts to drops),
this fires at error-observation time and treats a body whose
StreamingBody::is_end_stream already reports completion as complete,
both at construction (e.g. an empty body that is never polled) and after
its final frame (e.g. a content-length body read to its last byte, or a
chunked body whose terminal trailers frame was read, dropped before the
trailing poll_frame -> Ready(None)).
The closure is called at most once. The motivating use is connection reuse: a transport whose response was abandoned or errored mid-message must be marked non-reusable synchronously, before whatever guard releases it (e.g. back into a connection pool) runs — an asynchronous observer on the connection task loses that race to the next request.
Implementations§
§impl<B, F> OnIncompleteBody<B, F>
impl<B, F> OnIncompleteBody<B, F>
pub fn new(body: B, on_incomplete: F) -> OnIncompleteBody<B, F>
pub fn new(body: B, on_incomplete: F) -> OnIncompleteBody<B, F>
Wrap body, calling on_incomplete once if it errors or is abandoned
before end-of-stream.
Trait Implementations§
§impl<B, F> Body for OnIncompleteBody<B, F>
impl<B, F> Body for OnIncompleteBody<B, F>
§fn poll_frame(
self: Pin<&mut OnIncompleteBody<B, F>>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Frame<<OnIncompleteBody<B, F> as Body>::Data>, <OnIncompleteBody<B, F> as Body>::Error>>>
fn poll_frame( self: Pin<&mut OnIncompleteBody<B, F>>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Frame<<OnIncompleteBody<B, F> as Body>::Data>, <OnIncompleteBody<B, F> as Body>::Error>>>
§fn is_end_stream(&self) -> bool
fn is_end_stream(&self) -> bool
true when the end of stream has been reached. Read moreimpl<'__pin, B, F> Unpin for OnIncompleteBody<B, F>
Auto Trait Implementations§
impl<B, F> Freeze for OnIncompleteBody<B, F>
impl<B, F> RefUnwindSafe for OnIncompleteBody<B, F>
impl<B, F> Send for OnIncompleteBody<B, F>
impl<B, F> Sync for OnIncompleteBody<B, F>
impl<B, F> UnsafeUnpin for OnIncompleteBody<B, F>
impl<B, F> UnwindSafe for OnIncompleteBody<B, F>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<T> BodyExt for T
impl<T> BodyExt for T
§fn frame(&mut self) -> Frame<'_, Self> ⓘwhere
Self: Unpin,
fn frame(&mut self) -> Frame<'_, Self> ⓘwhere
Self: Unpin,
Frame, if any.§fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F>
fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F>
§fn capture<S>(self, sink: S) -> CaptureBody<Self, S>
fn capture<S>(self, sink: S) -> CaptureBody<Self, S>
§fn capture_buffered(
self,
limit: CaptureLimit,
) -> (CaptureBody<Self, BufferedBodyCapture>, CaptureHandle)
fn capture_buffered( self, limit: CaptureLimit, ) -> (CaptureBody<Self, BufferedBodyCapture>, CaptureHandle)
§fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
§fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
§fn collect_with(self, opts: CollectOptions) -> CollectWith<Self> ⓘ
fn collect_with(self, opts: CollectOptions) -> CollectWith<Self> ⓘ
CollectOptions. Read more§fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
§fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
BodyDataStream.§fn into_stream(self) -> BodyStream<Self>where
Self: Sized,
fn into_stream(self) -> BodyStream<Self>where
Self: Sized,
BodyStream. Read moreSource§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> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more