Skip to main content

reload_event_frame

Function reload_event_frame 

Source
pub fn reload_event_frame(change_type: &ChangeType) -> Bytes
Expand description

Encode a reload event as an SSE (Server-Sent Events) frame.

The frame follows the SSE text/event-stream format:

event: <change_type>
data: {"type": "<change_type>"}

This is the single canonical place the SSE frame format is defined. Callers that forward reload events over HTTP (e.g., mini-unified) call this function rather than re-implementing the byte-for-byte format.

The JSON payload is written directly rather than through a serializer: it is one fixed-shape object whose only value is one of ChangeType::as_str’s four literals, none of which contain a character JSON would need to escape. Pulling in a JSON dependency to emit eleven constant bytes is not a trade worth making.