Struct Body

#[must_use]
pub struct Body(/* private field */);

The body type used in axum requests and responses.

Implementations

impl Body

fn new<B>(body: B) -> Self
where
    B: Body<Data = Bytes> + Send + 'static,
    B::Error: Into<BoxError>,

Create a new Body that wraps another http_body::Body.

fn empty() -> Self

Create an empty body.

fn from_stream<S>(stream: S) -> Self
where
    S: TryStream + Send + 'static,
    S::Ok: Into<Bytes>,
    S::Error: Into<BoxError>,

Create a new Body from a Stream.

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

impl Body for Body

type Data = Bytes;
type Error = Error;
fn poll_frame(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>>
fn size_hint(&self) -> SizeHint
fn is_end_stream(&self) -> bool

impl Debug for Body

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Default for Body

fn default() -> Self

impl From<&'static [u8]> for Body

fn from(buf: &'static [u8]) -> Self

impl From<&'static str> for Body

fn from(buf: &'static str) -> Self

impl From<()> for Body

fn from(()) -> Self

impl From<Bytes> for Body

fn from(buf: Bytes) -> Self

impl From<Cow<'static, [u8]>> for Body

fn from(buf: Cow<'static, [u8]>) -> Self

impl From<Cow<'static, str>> for Body

fn from(buf: Cow<'static, str>) -> Self

impl From<String> for Body

fn from(buf: String) -> Self

impl From<Vec<u8>> for Body

fn from(buf: Vec<u8>) -> Self

impl IntoResponse for Body

fn into_response(self) -> Response

impl<S> FromRequest<S> for Body where S: Send + Sync,

type Rejection = never;
async fn from_request(req: Request, &S) -> Result<Self, Self::Rejection>

Auto Trait Implementations

impl !RefUnwindSafe for Body

impl !Sync for Body

impl !UnwindSafe for Body

impl Freeze for Body

impl Send for Body

impl Unpin for Body

impl UnsafeUnpin for Body

Blanket Implementations

impl<T> Any for Body where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> BodyExt for Body where T: Body + ?Sized,

impl<T> Borrow<T> for Body where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Body where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for Body

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for Body

impl<T> WithSubscriber for Body

impl<T, U> Into<U> for Body where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Body where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Body where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>