MoonSFV is a strict, dependency-free implementation of RFC 8941 Structured
Field Values for HTTP, written in
MoonBit. It fills the gap between HTTP applications and the modern structured
headers used by caching, privacy, client hints, and signature specifications.
Lists, inner lists, ordered dictionaries, duplicate-key rejection, and the
RFC true shorthand.
Strict parsing with byte offsets; malformed input is rejected rather than
repaired.
Canonical serialization that is stable on wasm, wasm-gc, JavaScript, and
native backends.
MoonSFV is not an HTTP client, server, HTTP Message Signatures implementation,
or a permissive parser for legacy headers.
Install
After publication:
moon add serene-WJ/moon_sfv
Library
test {
let field = @moon_sfv.parse_dictionary("a=(1 2);ok, b=:SGk=:")
inspect(@moon_sfv.serialize_dictionary(field), content="a=(1 2);ok, b=:SGk=:")
}
parse_item, parse_list, and parse_dictionary raise ParseError, whose
variants retain the failing byte offset and expected syntax. The public model
is BareItem, Item, InnerList, List, Dictionary, and Parameters.
CLI
moon run cmd/main -- normalize dictionary 'a=(1 2);ok, b=:SGk=:'
moon run cmd/main -- validate item '42;answer=?0'
moon run cmd/main -- parse list 'a, ("b" 2);level=3'
moon run cmd/main -- examples
The first command prints a=(1 2);ok, b=:SGk=:. Invalid input exits non-zero
and prints a compact JSON diagnostic on stderr.
Verification
moon fmt --check
moon check --target all --deny-warn
moon test --target all --deny-warn
moon info
moon package
GitHub Actions runs these commands, validates the CLI, checks the effective
MoonBit source footprint, and uploads the Mooncakes archive. The current
initial implementation enforces a 600-line production baseline; the planned
4k expansion is a future milestone and is not represented as complete here.
MoonSFV
MoonSFV is a strict, dependency-free implementation of RFC 8941 Structured Field Values for HTTP, written in MoonBit. It fills the gap between HTTP applications and the modern structured headers used by caching, privacy, client hints, and signature specifications.
Scope
trueshorthand.MoonSFV is not an HTTP client, server, HTTP Message Signatures implementation, or a permissive parser for legacy headers.
Install
After publication:
Library
parse_item,parse_list, andparse_dictionaryraiseParseError, whose variants retain the failing byte offset and expected syntax. The public model isBareItem,Item,InnerList,List,Dictionary, andParameters.CLI
The first command prints
a=(1 2);ok, b=:SGk=:. Invalid input exits non-zero and prints a compact JSON diagnostic on stderr.Verification
GitHub Actions runs these commands, validates the CLI, checks the effective MoonBit source footprint, and uploads the Mooncakes archive. The current initial implementation enforces a 600-line production baseline; the planned 4k expansion is a future milestone and is not represented as complete here.
RFC coverage
BareItem,serialize_bare_itemParameters,Parameters::getparse_item,serialize_itemInnerList,serialize_inner_listparse_list,serialize_listparse_dictionary,serialize_dictionaryLicense
MIT.