Caracola.Tokens (Caracola v0.1.0-rc.1)

Copy Markdown View Source

Parser for comma-separated token lists with parameters, as used in headers like Content-Type, Accept, Supported or Event. Port of NkLIB's nklib_parse_tokens.

iex> Caracola.Tokens.parse("multipart/mixed;boundary=7a9c, text/plain")
{:ok, [{"multipart/mixed", [{"boundary", "7a9c"}]}, {"text/plain", []}]}

Summary

Types

A token with its parameters.

Functions

Serializes a token or token list.

Parses a token list, or a list of such binaries.

Types

token()

@type token() :: {String.t(), [Caracola.URI.param()]}

A token with its parameters.

Functions

encode(token)

@spec encode(token() | [token()]) :: iodata()

Serializes a token or token list.

parse(values)

@spec parse(binary() | [binary()]) :: {:ok, [token()]} | :error

Parses a token list, or a list of such binaries.