ssevents

Canonical public surface for the ssevents package.

The focused modules (ssevents/event, ssevents/encoder, ssevents/decoder, ssevents/reconnect, ssevents/validate, ssevents/limit, ssevents/heartbeat, ssevents/stream, ssevents/error) carry the actual implementation, but they are an implementation detail: external code should prefer the spellings re-exported here. This is the surface the README and the published HexDocs documentation consider authoritative, and it is the surface that follows semver — the submodule shapes may be reorganized between releases.

Reach into a submodule directly only when the facade does not yet expose what you need; in that case, opening an issue so the missing entry point can be added at this level is preferred to scattering submodule imports across user code.

Types

pub type Event =
  event.Event
pub type Item =
  event.Item
pub type Iterator(a) =
  stream.Iterator(a)
pub type IteratorStep(a) =
  stream.Step(a)
pub type Limits =
  limit.Limits
pub type SseError =
  error.SseError

Values

pub fn comment(text: String) -> event.Item
pub fn content_type() -> String
pub fn data(event: event.Event, data: String) -> event.Event
pub fn data_of(event: event.Event) -> String
pub fn decode(
  input: String,
) -> Result(List(event.Item), error.SseError)
pub fn decode_bytes(
  input: BitArray,
) -> Result(List(event.Item), error.SseError)
pub fn decode_bytes_with_limits(
  input: BitArray,
  limits limits: limit.Limits,
) -> Result(List(event.Item), error.SseError)
pub fn decode_stream(
  chunks: stream.Iterator(BitArray),
) -> stream.Iterator(Result(event.Item, error.SseError))
pub fn decode_stream_with_limits(
  chunks: stream.Iterator(BitArray),
  limits limits: limit.Limits,
) -> stream.Iterator(Result(event.Item, error.SseError))
pub fn decode_with_limits(
  input: String,
  limits limits: limit.Limits,
) -> Result(List(event.Item), error.SseError)
pub const default_content_type: String
pub fn default_limits() -> limit.Limits
pub fn default_line_ending() -> encoder.LineEnding
pub fn empty_iterator() -> stream.Iterator(a)
pub fn encode(event: event.Event) -> String

Encode one semantic SSE Event to its wire-format String.

Use this when you want a text representation for logging, inspection, fixtures, or a caller that still expects String.

pub fn encode_bytes(event: event.Event) -> BitArray

Encode one semantic SSE Event to its wire-format BitArray.

Use this for HTTP responses and other byte-oriented transports.

pub fn encode_item(item: event.Item) -> String

Encode one Item (either an event or a comment) to String.

pub fn encode_item_bytes(item: event.Item) -> BitArray

Encode one Item (either an event or a comment) to BitArray.

pub fn encode_item_with_line_ending(
  item: event.Item,
  line_ending: encoder.LineEnding,
) -> String
pub fn encode_items(items: List(event.Item)) -> String

Encode a whole sequence of SSE items to one String.

pub fn encode_items_bytes(items: List(event.Item)) -> BitArray

Encode a whole sequence of SSE items to one BitArray.

pub fn encode_items_with_line_ending(
  items: List(event.Item),
  line_ending: encoder.LineEnding,
) -> String
pub fn encode_stream(
  items: stream.Iterator(event.Item),
) -> stream.Iterator(BitArray)
pub fn encode_with_line_ending(
  event: event.Event,
  line_ending: encoder.LineEnding,
) -> String
pub fn error_to_string(error: error.SseError) -> String
pub fn event(event: event.Event, name: String) -> event.Event
pub fn event_item(event: event.Event) -> event.Item
pub fn finish(
  state: decoder.DecodeState,
) -> Result(List(event.Item), error.SseError)
pub fn from_parts(
  event_name event_name: option.Option(String),
  data data: String,
  id id: option.Option(String),
  retry retry: option.Option(Int),
) -> event.Event
pub fn heartbeat() -> event.Item
pub fn id(event: event.Event, id: String) -> event.Event
pub fn id_of(event: event.Event) -> option.Option(String)
pub fn iterator_from_list(items: List(a)) -> stream.Iterator(a)
pub fn iterator_next(
  iterator: stream.Iterator(a),
) -> stream.Step(a)
pub fn iterator_to_list(iterator: stream.Iterator(a)) -> List(a)
pub fn last_event_id(
  state: reconnect.ReconnectState,
) -> option.Option(String)
pub fn last_event_id_header(
  state: reconnect.ReconnectState,
) -> option.Option(#(String, String))
pub fn limits() -> limit.Limits
pub fn max_data_bytes(
  event: event.Event,
  max: Int,
) -> Result(event.Event, error.SseError)
pub fn max_data_lines(limits: limit.Limits) -> Int
pub fn max_event_bytes(limits: limit.Limits) -> Int
pub fn max_line_bytes(limits: limit.Limits) -> Int
pub fn max_retry_value(limits: limit.Limits) -> Int
pub fn message(data: String) -> event.Event
pub fn name_of(event: event.Event) -> option.Option(String)
pub fn named(name: String, data: String) -> event.Event
pub fn new(data: String) -> event.Event
pub fn new_decoder_with_limits(
  limits: limit.Limits,
) -> decoder.DecodeState
pub fn new_limits(
  max_line_bytes max_line_bytes: Int,
  max_event_bytes max_event_bytes: Int,
  max_data_lines max_data_lines: Int,
  max_retry_value max_retry_value: Int,
) -> limit.Limits
pub const package_name: String
pub fn push(
  state: decoder.DecodeState,
  chunk: BitArray,
) -> Result(
  #(decoder.DecodeState, List(event.Item)),
  error.SseError,
)
pub fn retry(
  event: event.Event,
  milliseconds: Int,
) -> event.Event
pub fn retry_interval(
  state: reconnect.ReconnectState,
) -> option.Option(Int)
pub fn retry_of(event: event.Event) -> option.Option(Int)
pub fn validate_event_name(
  name: String,
) -> Result(String, error.SseError)
pub fn validate_id(id: String) -> Result(String, error.SseError)
pub fn validate_retry(
  milliseconds: Int,
) -> Result(Int, error.SseError)
Search Document