Skip to main content

Module contract

Module contract 

Source
Expand description

The one request contract, independent of transport.

A request is a method id, a Caller, JSON params, and a JSON result or a ServiceError. The local transport (framed JSON lines over a current-user-only socket or pipe) is an adapter onto it; a later transport maps onto the same types. This module holds no I/O.

Structs§

CallContext
What a handler knows about the request it is serving.
MethodPolicy
Policy for one method id: which local apps may call it and which scopes a device needs.
MethodTable
Every method of a service with its policy: the one source the local allowlist and a remote route table are both derived from. ping is never listed and always allowed.

Enums§

Caller
Who is making a request.
TableError
Why a method id or its policy was refused at table construction.
Transport
Which transports a method is reachable on.

Constants§

ROLE_SCOPE_PREFIX
A scope that names a role instead of a capability: role:<name>, for example role:operator.

Traits§

Handler

Functions§

role_of
The one role among scopes: Some only when exactly one scope is a role scope with a non-empty name. Two roles, or none, give None, so an ambiguous device never gets a role by the luck of an iteration order.
role_scope
The scope that grants role.
status_for_code
Status for a code; None when the table does not know it.
status_for_error
Status for an error: the table, else 503 when retryable, else 500.
validate_method_id
A method id must be a plain name: non-empty, no glob characters, whitespace, control characters, /, % or #.

Type Aliases§

Emit
Sends an event frame for the request being handled.
Scope
A capability a device holds (from enrolment). A plain label compared for equality.