pub enum ResponseChunk {
Headers {
status: u16,
headers: HashMap<String, String>,
},
Body(Bytes),
Return(Value),
Error(WorkerError),
End,
}Expand description
A chunk in a streaming response from a PHP worker.
The worker emits a sequence ending with End. Consumers read until End
(or the channel closes) to obtain the complete response.
A worker finalises a request in one of three shapes:
- streaming — one
Headerschunk followed by zero or moreBodychunks (the PHPfolk_write_head/folk_writeAPI); - return — a single
Returnchunk carrying the handler’s return value verbatim (non-streaming handlers: gRPC, jobs, and HTTP thatreturns an array); - error — a single
Errorchunk carrying a fatalWorkerError(uncaught exception, dispatch failure, malformed response).
Each shape is terminated by End. Consumers interpret Return themselves:
the HTTP plugin decodes the {status, headers, body} convention, while
gRPC/jobs use the value as-is.
Variants§
Headers
Response status and headers. Must be the first chunk (after optional EarlyHints).
Body(Bytes)
A piece of the response body.
Return(Value)
The worker’s return value, passed through verbatim.
Used by non-streaming handlers. The consumer decides how to interpret it
(the HTTP plugin decodes {status, headers, body}; gRPC/jobs use it
directly). Followed by End.
Error(WorkerError)
A fatal worker error (uncaught exception / dispatch failure).
Distinct from a business outcome, which travels as a normal
Return. Consumers translate this into a
transport-level failure (HTTP 500, gRPC INTERNAL). Followed by
End.
End
Signals that the response is complete.
Trait Implementations§
Source§impl Clone for ResponseChunk
impl Clone for ResponseChunk
Source§fn clone(&self) -> ResponseChunk
fn clone(&self) -> ResponseChunk
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more