AWSEventStream.Decoder (AWSEventStream v0.1.0)

Copy Markdown View Source

Incremental decoder for vnd.amazon.eventstream frames.

decode/2 consumes as many whole frames as the buffer holds and returns {results, rest}, where rest is leftover bytes to prepend to the next chunk. Frame-decode errors are surfaced as {:error, {reason, raw_frame}} results (never silently dropped); pass on_error: :skip to drop them.

Possible error reasons: :invalid_prelude_crc, :invalid_message_crc, :invalid_message_length, and :invalid_headers (the header block could not be parsed, e.g. an unknown header type or a value whose declared length runs past the frame). Malformed input is always surfaced as an error, never raised.

Summary

Types

result()

@type result() :: {:ok, AWSEventStream.Message.t()} | {:error, {atom(), binary()}}

Functions

decode(buffer, opts \\ [])

@spec decode(
  binary(),
  keyword()
) :: {[result()], binary()}