Skip to main content

Module rules

Module rules 

Source
Expand description

The rule builders config_schema is written in.

Public, and deliberately so. A Schema resolves a path by first match wins (rule_for returns the first rule whose pattern matches), so an application that keeps its own keys in a config document — prov permits a config surface to carry fields it never reads — composes by prepending its rules to config_rules:

let mut rules = my_app_rules();              // `myapp.*`, and any narrowing
rules.extend(provui_core::config_schema::config_rules(&config));
let schema = Schema::new(rules);

Prepending is what makes an overlay possible rather than only an addition: an app that wants a narrower vocabulary for a key this crate governs openly (views.*.group, say) puts its own rule first and shadows the generic one. Appending would leave the generic rule winning and the app’s rule dead.

These builders exist so an overlay’s rows come out looking like the ones beside them — same tints, same consequence vocabulary — without every frontend restating what a “costly” field looks like.

Functions§

choice
A closed pick-list: anything else is a value prov would ignore, so the editor rejects it rather than writing it and letting the default quietly win.
choice_terms
choice over terms already built.
costly
Mark a rule as one where every answer costs the same thing.
costly_when
Mark one answer as the costly one.
open_choice
An offered-but-not-enforced pick-list — for a vocabulary this crate cannot see the whole of (see metadata.format), or one where a value it does not know is still legitimate (see views.*.group).
open_choice_terms
open_choice over terms already built.
path
A dotted path pattern: * means “any key at this depth” (fields.*.type), [] means “each item of this sequence” (audiences.[].name).
present
A titled, icon-bearing presentation.
term
A vocabulary term with an optional one-line gloss (an empty gloss is none).
text
A free-text field.
toggle
A boolean field.