Skip to main content

Module protocol

Module protocol 

Source
Expand description

What crosses the pipe between the daemon and an addon.

ADR-0016. One JSON object per line, in both directions. Line-delimited rather than length-prefixed or a binary codec because this is a published interface: it has to be readable in a log, reproducible with echo, and implementable by an addon author who has not installed a code generator.

§Two shapes for one declaration, and why that is not two definitions

The trait declares actions as &'static [AddonAction], which is pleasant to write as a const and impossible to deserialise. So the types here are owned mirrors — ActionDecl beside AddonAction, and so on.

They are not two things to keep in step. The author writes the borrowed one once; run derives the owned one from it at the boundary. Nothing hand-maintains the second, so the failure Constitution VI is about — two definitions drifting — has nowhere to happen.

§Both directions, and why the addon speaks first only about credentials

Almost everything is the daemon asking and the addon answering. The one exception is Ask, which an addon sends while answering, when it needs one of its own credentials. That makes the conversation strictly nested — request, optional asks and their answers, reply — which is what lets Credentials stay a plain synchronous call in the addon’s code rather than infecting the trait with futures.

Structs§

ActionDecl
One action, owned. Mirrors AddonAction.
ChoiceDecl
One option, owned. Mirrors AddonChoice.
ChoicesDecl
One named list of options, owned. Mirrors AddonChoices.
Description
Everything static about an addon.
DeviceActionDecl
One device-resolved action, owned. Mirrors DeviceAction.
ParamDecl
One parameter, owned. Mirrors AddonParam.
SettingDecl
One setting, owned. Mirrors AddonSetting.
SignalDecl
One signal, owned. Mirrors AddonSignal.
Version
A protocol version.

Enums§

Answer
The daemon’s answer to an Ask.
Ask
A credential request, from the addon to the daemon.
AvailabilityDecl
Whether an addon can act, owned. Mirrors Availability.
FailureKind
Why an action failed, in the categories the daemon distinguishes.
KeystrokeDecl
One keystroke, owned. Mirrors DeviceKeystroke.
PermissionDecl
One permission, owned. Mirrors Permission.
ReadingDecl
A signal reading, owned. Mirrors Reading.
Reply
What an addon says back.
Request
What the daemon asks an addon to do.

Constants§

PROTOCOL
The protocol version this SDK speaks.