pub struct Body(/* private fields */);Expand description
The body type used in rama requests and responses.
Implementations§
Source§impl Body
impl Body
Sourcepub fn with_limit<B>(body: B, limit: usize) -> Body
pub fn with_limit<B>(body: B, limit: usize) -> Body
Create a new Body with a maximum size limit.
Sourcepub fn from_stream<S>(stream: S) -> Body
pub fn from_stream<S>(stream: S) -> Body
Create a new Body from a Stream.
Sourcepub fn on_drop<F>(self, on_drop: F) -> Body
pub fn on_drop<F>(self, on_drop: F) -> Body
Wrap this body so that on_drop is called if the body is dropped before
being fully consumed (e.g. because the client disconnected mid-response).
The closure fires exactly once and only on early drops — it is disarmed
when StreamingBody::poll_frame returns Poll::Ready(None).
Sourcepub fn with_trailer_headers(self, headers: HeaderMap) -> Body
pub fn with_trailer_headers(self, headers: HeaderMap) -> Body
Attach a headermap as trailer headers to this body.
In case you want this is also available as with_trailer,
provided by a body extension which allows you to use
a Future with as output an option of a result of a headermap.
This method is a shortcut of that function.
Sourcepub fn into_data_stream(self) -> BodyDataStream
pub fn into_data_stream(self) -> BodyDataStream
Convert the body into a Stream of data frames.
Non-data frames (such as trailers) will be discarded. Use http_body_util::BodyStream if
you need a Stream of all frame types.
Sourcepub fn into_event_stream<T>(self) -> EventStream<BodyDataStream, T>where
T: EventDataRead,
pub fn into_event_stream<T>(self) -> EventStream<BodyDataStream, T>where
T: EventDataRead,
Convert the body into a Stream of sse::Events.
https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events.
Sourcepub fn into_json_stream<T>(self) -> JsonReadStream<T, BodyDataStream>where
T: DeserializeOwned,
pub fn into_json_stream<T>(self) -> JsonReadStream<T, BodyDataStream>where
T: DeserializeOwned,
Convert the body into a JsonReadStream.
Stream of json objects, each object separated by a newline (\n).
Sourcepub fn into_json_stream_with_config<T>(
self,
cfg: ParseConfig,
) -> JsonReadStream<T, BodyDataStream>where
T: DeserializeOwned,
pub fn into_json_stream_with_config<T>(
self,
cfg: ParseConfig,
) -> JsonReadStream<T, BodyDataStream>where
T: DeserializeOwned,
Convert the body into a JsonReadStream.
Stream of json objects, each object separated by a newline (\n).
Sourcepub fn into_string_data_event_stream(self) -> EventStream<BodyDataStream>
pub fn into_string_data_event_stream(self) -> EventStream<BodyDataStream>
Convert the body into a Stream of sse::Events with optional string data.
https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events.
Trait Implementations§
Source§impl Body for Body
impl Body for Body
Source§fn poll_frame(
self: Pin<&mut Body>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Frame<<Body as Body>::Data>, <Body as Body>::Error>>>
fn poll_frame( self: Pin<&mut Body>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Frame<<Body as Body>::Data>, <Body as Body>::Error>>>
Source§fn size_hint(&self) -> SizeHint
fn size_hint(&self) -> SizeHint
Source§fn is_end_stream(&self) -> bool
fn is_end_stream(&self) -> bool
true when the end of stream has been reached. Read moreSource§impl From<InfiniteReader> for Body
impl From<InfiniteReader> for Body
Source§fn from(reader: InfiniteReader) -> Body
fn from(reader: InfiniteReader) -> Body
Source§impl IntoResponse for Body
impl IntoResponse for Body
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl !RefUnwindSafe for Body
impl !UnwindSafe for Body
impl Freeze for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnsafeUnpin for Body
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
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>
Source§fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F>
fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F>
Source§fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
Source§fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
Source§fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
Source§fn collect_with(self, opts: CollectOptions) -> CollectWith<Self> ⓘ
fn collect_with(self, opts: CollectOptions) -> CollectWith<Self> ⓘ
CollectOptions. Read moreSource§fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
Source§fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
BodyDataStream.Source§fn into_stream(self) -> BodyStream<Self>where
Self: Sized,
fn into_stream(self) -> BodyStream<Self>where
Self: Sized,
BodyStream.Source§impl<B> BodyExtractExt for B
impl<B> BodyExtractExt for B
Source§async fn try_into_json<T>(self) -> Result<T, Box<dyn Error + Sync + Send>>where
T: DeserializeOwned + Send + 'static,
async fn try_into_json<T>(self) -> Result<T, Box<dyn Error + Sync + Send>>where
T: DeserializeOwned + Send + 'static,
Source§async fn try_into_json_streaming<T>(
self,
) -> Result<T, Box<dyn Error + Sync + Send>>where
T: DeserializeOwned + Send + 'static,
async fn try_into_json_streaming<T>(
self,
) -> Result<T, Box<dyn Error + Sync + Send>>where
T: DeserializeOwned + Send + 'static,
Source§async fn try_into_string(self) -> Result<String, Box<dyn Error + Sync + Send>>
async fn try_into_string(self) -> Result<String, Box<dyn Error + Sync + Send>>
Source§async fn try_capture_json(
self,
selectors: impl IntoIterator<Item = JsonPath> + Send,
max_capture_bytes: usize,
) -> Result<Vec<OwnedCapturedValue>, Box<dyn Error + Sync + Send>>
async fn try_capture_json( self, selectors: impl IntoIterator<Item = JsonPath> + Send, max_capture_bytes: usize, ) -> Result<Vec<OwnedCapturedValue>, Box<dyn Error + Sync + Send>>
selectors while streaming over the body. Read moreSource§async fn try_into_json_with<T>(
self,
opts: CollectOptions,
) -> Result<T, CollectError>where
T: DeserializeOwned + Send + 'static,
async fn try_into_json_with<T>(
self,
opts: CollectOptions,
) -> Result<T, CollectError>where
T: DeserializeOwned + Send + 'static,
Source§async fn try_into_string_with(
self,
opts: CollectOptions,
) -> Result<String, CollectError>
async fn try_into_string_with( self, opts: CollectOptions, ) -> Result<String, CollectError>
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
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>
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