pub enum RequestBody {
Empty,
Full(Bytes),
Rewindable(RewindFactory),
Streaming(Box<dyn Body<Data = Bytes, Error = Error> + Unpin + Send>),
}Expand description
A request body with an explicit replay contract.
Variants§
Empty
Full(Bytes)
Rewindable(RewindFactory)
Replays by calling the factory.
Factory contract. It must be pure: every call must produce a body
equivalent to the previous one (same content, same size). A factory
with hidden state that hands back a different body on each call is a
bug source that’s obvious in hindsight but undocumented otherwise,
which is why size_hint() deliberately returns None for this
variant: guessing from the first call is dangerous if the contract
is violated.
The factory is legally allowed to return RequestBody::Streaming —
that isn’t a live lie, because retry_kind() and rewind() are
always recomputed from whatever object currently sits inside
RequestBody, not cached at the moment Rewindable was created.
Invariant that matters for the retry layer: always ask
retry_kind() of the body you’re currently holding, and never cache
it across a rewind().
Streaming(Box<dyn Body<Data = Bytes, Error = Error> + Unpin + Send>)
A single-pass body. The concrete stream is set by the transport; in v0.1 the core only needs to know it can’t be replayed.
+ Send — the same C2 exception as RewindFactory: Box<T>: Send
requires only T: Send, Sync isn’t needed here.