Skip to main content

ResponseChunk

Enum ResponseChunk 

Source
pub enum ResponseChunk {
    Headers {
        status: u16,
        headers: Vec<(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 Headers chunk followed by zero or more Body chunks (the PHP folk_write_head / folk_write API);
  • return — a single Return chunk carrying the handler’s return value verbatim (non-streaming handlers: gRPC, jobs, and HTTP that returns an array);
  • error — a single Error chunk carrying a fatal WorkerError (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).

headers is an ordered list of (name, value) pairs — NOT a map — so a header that legitimately repeats (notably Set-Cookie, whose value can itself contain a comma in an Expires date) survives as distinct entries instead of being folded into one corrupted value (folk-releases #86).

Fields

§status: u16
§headers: Vec<(String, String)>
§

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResponseChunk

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more