ssevents/encoder
Deterministic Server-Sent Events encoding.
The default line ending is LF. Call the *_with_line_ending
variants to emit CRLF instead.
Types
pub type LineEnding {
Lf
Crlf
}
Constructors
-
Lf -
Crlf
Values
pub fn default_line_ending() -> LineEnding
pub fn encode(event: event.Event) -> String
Encode one semantic SSE Event to its wire-format String (LF
line ending).
Determinism invariant (#72): the encoded bytes depend only on
the value of the Event, not on the builder call sequence used to
construct it. For any two structurally equal Event values
(Event.from_parts(...) with the same fields, or any sequence of
builder calls that ends in the same field assignment),
encode(a) == encode(b) byte-for-byte. The same invariant holds
across the BEAM and JavaScript targets, so caches, signatures, and
content-addressable storage on the wire are stable across runtimes.
pub fn encode_bytes(event: event.Event) -> BitArray
pub fn encode_item(item: event.Item) -> String
pub fn encode_item_bytes(item: event.Item) -> BitArray
pub fn encode_item_with_line_ending(
item: event.Item,
line_ending: LineEnding,
) -> String
pub fn encode_items(items: List(event.Item)) -> String
pub fn encode_items_bytes(items: List(event.Item)) -> BitArray
pub fn encode_items_with_line_ending(
items: List(event.Item),
line_ending: LineEnding,
) -> String
pub fn encode_with_line_ending(
event: event.Event,
line_ending: LineEnding,
) -> String