src/body.rs

axum · axum-core/src/body.rs · rust · MIT
integration, Integration / API

Provides a boxed HTTP body type with utilities for axum web framework.

// Source: https://github.com/tokio-rs/axum | License: MIT | Copyright 2019–2025 axum Contributors
// Provided via justclaw.it.com; keep this notice with the code.
//! HTTP body utilities.

mod unknown;
pub(crate) use unknown::Unknown;

use crate::{BoxError, Error};
use bytes::Bytes;
use futures_core::{Stream, TryStream};
use http_body::{Body as _, Frame};
use http_body_util::BodyExt;
use pin_project_lite::pin_project;
use std::pin::Pin;
use std::task::{ready, Context, Poll};
use sync_wrapper::SyncWrapper;

type BoxBody = http_body_util::combinators::UnsyncBoxBody<Bytes, Error>;

fn boxed<B>(body: B) -> BoxBody
where
    B: http_body::Body<Data = Bytes> + Send + 'static,
    B::Error: Into<BoxError>,
{
    try_downcast(body).unwrap_or_else(|body| body.map_err(Error::new).boxed_unsync())
}


... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key