Pixir.Provider.SSEDecoder (pixir v0.1.12)

Copy Markdown View Source

Incremental, bounded WHATWG event-stream framing for the portable Open Responses HTTP/SSE profile.

This module owns framing only. Pixir.Provider owns JSON reduction, strict event:/body-type agreement, and terminal interpretation. The decoder never includes payload bytes in errors or diagnostics. It is deliberately selected only for open_responses; the accepted ChatGPT/Codex compatibility reducer remains separate.

Summary

Types

A framed data payload. event is nil when no event field was supplied.

t()

Opaque incremental decoder state.

Functions

Feed one arbitrary transport chunk and return zero or more ordered frames.

Finish framing, discarding any pending non-dispatched event per WHATWG.

Maximum accepted bytes in one undecoded event, including framing.

Create an empty strict decoder.

Types

frame()

@type frame() :: %{event: String.t() | nil, data: binary(), ordinal: pos_integer()}

A framed data payload. event is nil when no event field was supplied.

t()

@opaque t()

Opaque incremental decoder state.

Functions

feed(decoder, bytes)

@spec feed(t(), binary()) ::
  {:ok, t(), [frame() | :done]} | {:error, t(), [frame() | :done], map()}

Feed one arbitrary transport chunk and return zero or more ordered frames.

finish(decoder)

@spec finish(t()) :: {:ok, t(), [frame() | :done], map()} | {:error, t(), map()}

Finish framing, discarding any pending non-dispatched event per WHATWG.

max_event_bytes()

@spec max_event_bytes() :: pos_integer()

Maximum accepted bytes in one undecoded event, including framing.

new()

@spec new() :: t()

Create an empty strict decoder.