Figler.Sparse (figler v0.1.0-beta.1)

Copy Markdown View Source

Helpers for sparse schema-backed Kiwi maps.

Sparse maps are produced by Figler.decode_sparse_message/1. They contain a :__kiwi_module__ key with the generated schema module and only the fields present in the encoded payload.

Summary

Functions

Fetches a sparse field value.

Returns sparse field keys, excluding metadata.

Gets a sparse field value.

Returns the generated schema module for a sparse map.

Returns whether a sparse field was present on the wire.

Types

t()

@type t() :: %{:__kiwi_module__ => module(), optional(atom()) => term()}

Functions

fetch(sparse, field)

@spec fetch(t(), atom()) :: {:ok, term()} | :error

Fetches a sparse field value.

fields(sparse)

@spec fields(t()) :: [atom()]

Returns sparse field keys, excluding metadata.

get(sparse, field, default \\ nil)

@spec get(t(), atom(), term()) :: term()

Gets a sparse field value.

module(map)

@spec module(t()) :: module()

Returns the generated schema module for a sparse map.

present?(sparse, field)

@spec present?(t(), atom()) :: boolean()

Returns whether a sparse field was present on the wire.