Skip to main content

StreamHandler

Type Alias StreamHandler 

Source
pub type StreamHandler = Arc<dyn Fn(Value) -> BoxStream<'static, StreamFrame> + Send + Sync>;
Expand description

Type-erased async streaming handler — used for subscriptions (SPEC §4.2).

Takes a JSON Value (the request input) and returns a BoxStream of StreamFrames. Each yielded frame maps to one SSE event per SPEC §4.2: StreamFrame::Data becomes event: data, StreamFrame::Error becomes event: error. End-of-stream is implicit — when the stream finishes, the router emits the closing event: end\ndata:\n\n frame.

Aliased Type§

pub struct StreamHandler { /* private fields */ }