MessageSignatures.Component (MessageSignatures v0.1.0)

Copy Markdown View Source

A covered-component identifier (RFC 9421 Section 2): an sf-string naming either a derived component or an HTTP field, plus optional parameters.

Parameter order is preserved exactly as parsed because the signature base and @signature-params line must reproduce it byte-for-byte.

Summary

Functions

All derived component names.

The bare-item value of a parameter, or nil.

True when the req parameter is set.

Canonical identifier string as it appears in the signature base.

The component without its req parameter.

Resolves a component to its base-line values against a message.

Types

bare_item()

@type bare_item() ::
  {:integer, integer()}
  | {:decimal, float()}
  | {:string, String.t()}
  | {:token, String.t()}
  | {:binary, binary()}
  | {:boolean, boolean()}

item()

@type item() :: {:item, bare_item(), params()}

params()

@type params() :: [{String.t(), bare_item()}]

t()

@type t() :: %MessageSignatures.Component{name: String.t(), params: params()}

Functions

derived_names()

@spec derived_names() :: [String.t()]

All derived component names.

from_item(arg1)

@spec from_item(item()) :: {:ok, t()} | {:error, MessageSignatures.Error.t()}

param(component, key)

@spec param(t(), String.t()) :: bare_item() | nil

The bare-item value of a parameter, or nil.

parse(string)

@spec parse(String.t()) :: {:ok, t()} | {:error, MessageSignatures.Error.t()}

req?(component)

@spec req?(t()) :: boolean()

True when the req parameter is set.

serialize(component)

@spec serialize(t()) :: String.t()

Canonical identifier string as it appears in the signature base.

strip_req(component)

@spec strip_req(t()) :: t()

The component without its req parameter.

to_item(component)

@spec to_item(t()) :: item()

value(component, message, opts)

@spec value(t(), MessageSignatures.Message.t(), keyword()) ::
  {:ok, [String.t()]} | {:error, MessageSignatures.Error.t()}

Resolves a component to its base-line values against a message.

Every successfully resolved component yields a one-element list.