Struct Body
pub struct Body(/* private fields */);
Expand description
The body type used in rama requests and responses.
Implementations§
§impl Body
impl Body
pub 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.
pub fn from_stream<S>(stream: S) -> Body
pub fn from_stream<S>(stream: S) -> Body
Create a new Body
from a Stream
.
pub 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.
pub 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::Event
s.
https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events.
pub fn into_json_stream<T>(self) -> JsonStream<T, BodyDataStream>where
T: DeserializeOwned,
pub fn into_json_stream<T>(self) -> JsonStream<T, BodyDataStream>where
T: DeserializeOwned,
Convert the body into a [JsonStream
].
Stream of json objects, each object separated by a newline (\n
).
pub fn into_json_stream_with_config<T>(
self,
cfg: ParseConfig,
) -> JsonStream<T, BodyDataStream>where
T: DeserializeOwned,
pub fn into_json_stream_with_config<T>(
self,
cfg: ParseConfig,
) -> JsonStream<T, BodyDataStream>where
T: DeserializeOwned,
Convert the body into a [JsonStream
].
Stream of json objects, each object separated by a newline (\n
).
pub 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::Event
s with optional string data.
https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events.
Trait Implementations§
§impl From<InfiniteReader> for Body
impl From<InfiniteReader> for Body
§fn from(reader: InfiniteReader) -> Body
fn from(reader: InfiniteReader) -> Body
§impl IntoResponse for Body
impl IntoResponse for Body
§fn into_response(self) -> Response
fn into_response(self) -> Response
§impl Body for Body
impl Body for Body
§type Error = OpaqueError
type Error = OpaqueError
Body
might generate.§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>>>
§fn is_end_stream(&self) -> bool
fn is_end_stream(&self) -> bool
true
when the end of stream has been reached. Read moreAuto Trait Implementations§
impl Freeze for Body
impl !RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl !UnwindSafe for Body
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 boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
§fn collect(self) -> Collect<Self> ⓘwhere
Self: Sized,
fn collect(self) -> Collect<Self> ⓘwhere
Self: Sized,
Collected
body which will collect all the DATA frames
and trailers.§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
.§impl<B> BodyExtractExt for B
impl<B> BodyExtractExt for B
§async fn try_into_json<T>(self) -> Result<T, OpaqueError>where
T: DeserializeOwned + Send + 'static,
async fn try_into_json<T>(self) -> Result<T, OpaqueError>where
T: DeserializeOwned + Send + 'static,
§async fn try_into_string(self) -> Result<String, OpaqueError>
async fn try_into_string(self) -> Result<String, OpaqueError>
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<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> 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