Skip to main content

Effect

Derive Macro Effect 

Source
#[derive(Effect)]
{
    // Attributes available to this derive:
    #[effect]
    #[param]
}
Expand description

Derive Effect: an enum’s variants become the app’s published effects — work with no document delta, invoked by buttons, the palette, agents and scripts alike. See tilo_resource::effect.

#[effect(operation = "app.effects")] names the vocabulary’s operation type. Each variant is unit or has named fields (the effect’s typed parameters, #[param("…")] describing one); its id is the variant name in kebab case and its label the crate’s catalogue message <operation>-<id> (separators as dashes), or the key label = "..." names. #[effect(catalogue = "dir")] on the enum reads another catalogue than locales/. Variant options: #[effect(label = "key", view, document, prompted, row, job, cancellable, returns, destructive, privileged, idempotent, own_device, attended, screen, audience = "agents", untrusted, opens_path, member, risk = "path", kind = "read", host_render, tag = some::TAG)]. host_render marks an effect a host answers in a render service of its own rather than the record’s app worker; tag (repeatable) adds a contract tag, a &'static str constant; outside_with = "path" makes a kind = "read" effect reach outside only when that parameter is given (an export writing the file it names). document publishes the effect as a document operation the app’s own registry applies to its record, as the history verbs are; its operation type is the action’s, never an operation the surface answers. prompted keeps a named verb’s prompt in the palette where every parameter may be left out (undo asks how many steps). item = field offers it on each item of a collection, its first parameter bound to the item’s id; on = RowType offers it on each row of a #[derive(Row)] type, bound to the row’s id. Who may run an effect is decided by what it declares, like any action. Every effect states its kind: kind = "read", "undoable" or "outside" (a change checked against the caller’s grants). view implies read, edit implies undoable, and an effect that names none of them does not build. A screen effect only changes what is on the screen it is invoked on (a form, a panel, a place it shows): it reads, answers nothing, only the person at that screen invokes it and no agent is listed it. An own_device effect’s whole scope is the invoking person’s own device, touching nothing shared and no one else (their clipboard, their own appearance): a room’s grants have nothing to consent to. An attended effect needs its person attending (a chooser, a sign-in, a secret shown): whoever acts for them is always asked first, while the person’s own click is their decision and, like an own_device effect, needs no room’s consent and runs only on their own device. Generates impl Effect and one ActionRef constant per variant (Backups::RESTORE) for binding controls.