Skip to main content

rightkit_daemon/contract/
mod.rs

1//! The one request contract, independent of transport.
2//!
3//! A request is a method id, a [`Caller`], JSON params, and a JSON result or a
4//! [`ServiceError`](crate::ServiceError). The local transport (framed JSON lines over a
5//! current-user-only socket or pipe) is an adapter onto it; a later transport maps onto the same
6//! types. This module holds no I/O.
7//!
8//! * [`Caller`] says who is asking: a local app (OS-verified peer) or a device (id and scopes).
9//! * [`MethodTable`] is the single source of method policy ([`MethodPolicy`]); the local
10//!   [`Allowlist`](crate::Allowlist) is derived from it ([`MethodTable::allowlist`]) and
11//!   [`MethodTable::authorize`] answers for any caller.
12//! * [`Handler`], [`CallContext`] and [`Emit`] are the serving side.
13//! * [`status_for_code`] maps an error code to an HTTP-style status for transports that need one.
14
15mod caller;
16mod handler;
17mod method;
18mod status;
19
20pub use caller::{role_of, role_scope, Caller, Scope, ROLE_SCOPE_PREFIX};
21pub use handler::{CallContext, Emit, Handler};
22pub use method::{validate_method_id, MethodPolicy, MethodTable, TableError, Transport};
23pub use status::{status_for_code, status_for_error};
24
25pub(crate) use handler::new_context;
26pub(crate) use method::authorize_allowlist;