Documentation
¶
Overview ¶
Package codec is the port between a manifest's text and its document. The engine validates and reasons about documents (the generic map a schema validates, or a typed view of one); what text those documents are written in is an adapter's business. YAML is the one the vaults are written in; the json adapter beside it proves the seam and gives a database-backed deployment a text its own tools read.
A store carries the text the codec produced, byte for byte, so versions and diffs are over what the person wrote. Changing the codec of an existing vault is therefore a migration (export, re-encode, import), not a flag.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec interface {
// Name is the codec's short name, "yaml" or "json".
Name() string
// Extension is the file extension a vault uses for this codec's
// files, with the dot: ".yaml".
Extension() string
// Decode parses text into the generic document a schema validates.
Decode(text []byte) (map[string]any, error)
// DecodeAll parses a text that may hold several manifests (YAML's
// "---"), each with its own bytes; a syntax with no such notion
// returns one. An empty document is skipped, not reported.
DecodeAll(text []byte) ([]Document, error)
// DecodeInto parses text into a typed value. Field names follow the
// value's `yaml` tags, which every typed view in the engine carries;
// an adapter for another syntax maps its names onto those.
DecodeInto(text []byte, v any) error
// Encode writes a document, or a typed value, as canonical text: the
// form a vault file is saved in, stable across runs.
Encode(v any) ([]byte, error)
}
Codec turns manifest text into documents and back.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package conformance is the suite every codec.Codec adapter must pass: what the engine relies on, written once, run against each syntax.
|
Package conformance is the suite every codec.Codec adapter must pass: what the engine relies on, written once, run against each syntax. |
|
Package json is the JSON codec.
|
Package json is the JSON codec. |
|
Package yaml is the YAML codec: yaml.v3 to read, yamlfmt to write, so a file saved by Cartograph keeps the two-space indentation the vaults are written in by hand.
|
Package yaml is the YAML codec: yaml.v3 to read, yamlfmt to write, so a file saved by Cartograph keeps the two-space indentation the vaults are written in by hand. |