Mirrors Rust's #[serde(untagged)] enum MatchSpec { Literal(String), Structured(MatchRule) } (template.rs:184-187). An Elixir "untagged enum"
is a tagged tuple here ({:literal, string} / {:structured, match_rule})
since Elixir has no untagged-union deserialization primitive to mirror
directly -- the tag is added, not removed, information.
Summary
Types
@type t() :: {:literal, String.t()} | {:structured, GgenIgniter.Frontmatter.MatchRule.t()}
Functions
Wraps a literal substring/marker pattern as a t/0, tagging it :literal
the way the real Rust untagged enum's MatchSpec::Literal(String) variant
is distinguished from MatchSpec::Structured(MatchRule) at the type level.
Examples
iex> GgenIgniter.Frontmatter.MatchSpec.literal("ggen:slot")
{:literal, "ggen:slot"}
@spec structured(GgenIgniter.Frontmatter.MatchRule.t()) :: t()
Wraps a GgenIgniter.Frontmatter.MatchRule.t() as a t/0, tagging it
:structured -- the counterpart to literal/1 above.
Examples
iex> rule = GgenIgniter.Frontmatter.MatchRule.from_map(%{"pattern" => "ggen:slot"})
iex> GgenIgniter.Frontmatter.MatchSpec.structured(rule)
{:structured,
%GgenIgniter.Frontmatter.MatchRule{
pattern: "ggen:slot",
matcher: :contains,
scope: :auto,
occurrence: :first,
index: 0,
case_sensitive: true,
trim: false
}}