pub enum ReplyData {
Json(Value),
Bytes {
content_type: Cow<'static, str>,
data: Vec<u8>,
},
Empty,
Rich(Box<ReplySpec>),
Stream(BodyStream),
Upgrade(Box<dyn Any + Send>),
}Expand description
Variants§
Json(Value)
A JSON body (Content-Type: application/json).
Bytes
Raw bytes plus the Content-Type to send. There is no default —
callers pick the type at the call site (application/zip,
image/png, application/octet-stream, …). Construct via
bytes(). The finalizer emits the header verbatim.
Fields
Empty
An empty body — 204 No Content by default.
Rich(Box<ReplySpec>)
A reply carrying explicit status / headers (a ReplySpec) on top of
one of the other payload kinds.
Stream(BodyStream)
A streaming body, written out as the stream yields.
Upgrade(Box<dyn Any + Send>)
An HTTP connection-upgrade reply (e.g. WebSocket). Produced by
actus::ws::upgrade(...) (with the websocket feature) and consumed
by the server, which completes the handshake (101 Switching Protocols)
and then hands the upgraded connection to the handler. The boxed value
is opaque server plumbing — don’t construct or inspect it directly.
Implementations§
Source§impl ReplyData
impl ReplyData
Sourcepub fn add_header(&mut self, name: impl Into<String>, value: impl Into<String>)
pub fn add_header(&mut self, name: impl Into<String>, value: impl Into<String>)
Add a response header. Lifts self into ReplyData::Rich if the
current variant doesn’t already carry headers (Json/Bytes/Empty/Stream),
so middleware after hooks (and any code that has a ReplyData it
wants to decorate) can stamp headers without manually wrangling
ReplySpec. The original payload is preserved.
No-op on ReplyData::Upgrade — that variant is intercepted by the
server before the response body is finalized, and lifting it into
Rich would hide it from that interception.
Sourcepub fn set_status(&mut self, status: StatusCode)
pub fn set_status(&mut self, status: StatusCode)
Set the response status, lifting into ReplyData::Rich if needed
(see add_header).