Skip to main content

generate_codecs

Function generate_codecs 

Source
pub fn generate_codecs(
    root: &Path,
    mode: CodegenMode,
) -> Result<CodecReport, CodegenError>
Expand description

Generates (or, in CodegenMode::Check, verifies) the package’s codecs module src/<package>_codecs.gleam from its schemas/*.json.

The codecs are derived from the schemas alone — not the activity declarations — so this can run before the package’s manifest() is executed to extract the declarations: the author’s activities module references codecs.<type>_codec(), which must already compile for the extraction build to succeed. generate_activities emits the remaining plumbing (wrappers, worker, golden) once the declarations are known.

§Errors

Returns a CodegenError for an unreadable gleam.toml/schemas/, an unsupported schema construct, a write failure, or — in check mode — a missing or drifted codecs module.