Expand description
build.rs codegen for skilj’s own declarative bounded-context
format, Codeberg issue #5’s “narrower cut” (see docs/architecture.md
§17 for the full design, and §16 for the prototype that scoped it
down to this). A .skilj.toml file describes one bounded context’s
event/command type shapes only, fields, DCB tags and
rest_trigger_allowed, and this crate turns that into real Rust:
one payload struct and one EventType/CommandType impl per
declared type, plus the shared per-bounded-context event enum and
its BoundedContextEvent impl.
Deliberately narrow, not a gap to widen casually.
sensitive_fields, the event creation-origin flags
(external_creation_allowed/direct_creation_allowed/
event_read_allowed), scheduling, #[requires_role], and every
Projection concept are real, legitimate parts of the plugin API
this format doesn’t cover - the §16 prototype’s own recommendation
was to prove the mechanism on exactly what a real conversion needed
(skilj-demo/src/banking.rs, which uses none of those), not to
guess ahead of a second real use case.
decide()/project() stay hand-written Rust, always. A
generated CommandType::decide() is one line, delegating to a
plain free function (decide_<snake_case(NAME)>) the including
module is expected to already define - see emit::emit_command_type’s
own doc comment. This crate never sees, needs, or could sensibly
generate real domain logic.
How a consumer uses this: from its own build.rs, call
generate on a .skilj.toml file’s contents, write the result to
$OUT_DIR, and include!() it from the hand-written module that
also defines the decide_* functions. See
skilj-demo/build.rs/skilj-demo/src/banking.rs for the real,
working example.
Structs§
Enums§
- Error
- Field
Type - The scalar leaf shapes the plugin API’s own schema rules already
require for a
tag_mappings/sensitive_fieldstarget (see theskiljskill’s ownreferences/event-type.md) - not a general type system. A payload field this format can’t express (a nested object, an enum, a list) stays a reason to hand-write that one type instead of describing it here, not a gap to widen this enum for casually.
Functions§
- generate
- Parses
toml_source(a.skilj.tomlfile’s own contents) and returns real,prettyplease-formatted Rust source - genuinely readable when a consumer’s ownbuild.rswrites it to$OUT_DIRfor debugging, not a minified one-liner. See this crate’s own root doc comment for what the output covers.