pub struct Body(/* private fields */);
Expand description
The body type used in rama requests and responses.
Implementations§
Source§impl Body
impl Body
Sourcepub fn new<B>(body: B) -> Body
pub fn new<B>(body: B) -> Body
Create a new Body
that wraps another http_body::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 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.
Trait Implementations§
Source§impl Body for Body
impl Body for Body
Source§type Error = OpaqueError
type Error = OpaqueError
The error type this
Body
might generate.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>>>
Attempt to pull out the next data buffer of this stream.
Source§fn size_hint(&self) -> SizeHint
fn size_hint(&self) -> SizeHint
Returns the bounds on the remaining length of the stream. Read more
Source§fn is_end_stream(&self) -> bool
fn is_end_stream(&self) -> bool
Returns
true
when the end of stream has been reached. Read moreSource§impl IntoResponse for Body
impl IntoResponse for Body
Source§fn into_response(self) -> Response<Body>
fn into_response(self) -> Response<Body>
Create a response.
Auto 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§
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<B> BodyExtractExt for B
impl<B> BodyExtractExt for B
Source§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,
Try to deserialize the (contained) body as a JSON object.
Source§async fn try_into_string(self) -> Result<String, OpaqueError>
async fn try_into_string(self) -> Result<String, OpaqueError>
Try to turn the (contained) body in an utf-8 string.
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> 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>
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