body
Policy-managed body lifecycle primitives for Rust systems.
body is about the lifecycle of payloads: limits, draining, replay,
shutdown, failure semantics, observability, and ownership boundaries.
It does not replace http-body, http-body-util, hyper, tower, or
bytes. Those crates provide excellent protocol-level and utility-level
building blocks. body aims to provide a higher-level policy layer around
them.
Status
body is an early foundation release.
The initial API is intentionally small: it establishes the vocabulary, policy
types, and lifecycle model that later protocol integrations will build on.
Support for http-body, hyper, tower, and async runtimes is planned as the
semantics settle.
Why
Bodies are not just bytes.
A request, response, message, stream, or payload body has operational consequences:
- it may be streamed, buffered, rejected, drained, replayed, or aborted
- it may exceed limits
- it may begin as a future body that is not a stream yet
- it may outlive the request or message head
- it may affect connection reuse
- it may interact with graceful shutdown
- it may need observability and accounting
- it may need different behavior under upstream failure
body exists to make those semantics explicit.
Protocol Independence
body is protocol-independent.
It treats a body as a payload lifecycle boundary, not as an HTTP-only type. HTTP request and response bodies are important use cases, but the same policy questions appear in TCP, Unix sockets, UDP, QUIC, WebTransport, WebSocket, RPC, uploads, downloads, and other streamed payload systems.
Protocol integrations will come later as optional crates or features.
Non-goals
- This crate does not replace
http-body. - This crate does not compete with
http-body-util. - This crate does not hide protocol crates behind a large framework.
- This crate does not force a single async runtime.
- This crate does not promise every protocol integration in
0.1.
Initial API
The first public API focuses on policy and lifecycle vocabulary:
BodyPolicyBodyStateBodyGuardBodyDecisionOverflowPolicyDropPolicyDrainPolicyReplayPolicyShutdownPolicy
Example
use ;
let mut body = new
.max_bytes
.overflow;
assert_eq!;
assert_eq!;
Planned timeline
0.1
Foundation release.
- core policy types
- lifecycle state model
- minimal
BodyGuard<B> - protocol-independent byte accounting decisions
- documentation of semantics and non-goals
0.2
HTTP body integration.
http-bodycompatibility- byte counting
- limit enforcement
- error classification
0.3
Operational semantics.
- drain helpers
- timeout hooks
- shutdown behavior
- observability hooks
0.4
Integration layer.
- optional
hypersupport - optional
towersupport - test bodies for slow, endless, partial, and failing streams
Philosophy
The head declares intent.
The body carries consequence.