ssevents/stream

Lightweight iterator utilities for chunk-based encode/decode flows.

The current gleam_stdlib version used by this repository does not ship a general-purpose iterator module, so ssevents provides a tiny local one for its own stream adapters.

Types

pub opaque type Iterator(a)
pub type Step(a) {
  Next(item: a, rest: Iterator(a))
  Done
}

Constructors

Values

pub fn append(
  left: Iterator(a),
  right: Iterator(a),
) -> Iterator(a)
pub fn decode_stream(
  chunks: Iterator(BitArray),
) -> Iterator(Result(event.Item, error.SseError))
pub fn decode_stream_with_limits(
  chunks: Iterator(BitArray),
  limits limits: limit.Limits,
) -> Iterator(Result(event.Item, error.SseError))
pub fn empty() -> Iterator(a)
pub fn encode_stream(
  items: Iterator(event.Item),
) -> Iterator(BitArray)
pub fn from_list(items: List(a)) -> Iterator(a)
pub fn map(
  over iterator: Iterator(a),
  with f: fn(a) -> b,
) -> Iterator(b)
pub fn next(iterator: Iterator(a)) -> Step(a)
pub fn single(item: a) -> Iterator(a)
pub fn to_list(iterator: Iterator(a)) -> List(a)
Search Document