1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Cross-service registration contract for unified OpenRPC documents.
//!
//! Why: The trusty-* ecosystem is moving toward a host process (open-mpm /
//! a unified daemon) that links several MCP services into one binary and
//! exposes a single `rpc.discover` document covering all of them. Each
//! linked service needs a uniform way to advertise its tools, version, and
//! per-tool scope requirements without the host having to know about each
//! service concretely. A trait object solves this: services register an
//! impl, the host collects `&dyn ServiceDescriptor` and feeds them to
//! `OpenRpcBuilder::from_services` to emit one merged manifest.
//!
//! What: A single trait, `ServiceDescriptor`, with four methods covering
//! identity (`name`, `version`), the tool list (MCP-shape JSON), and a
//! per-tool scope lookup. Trait objects are `Send + Sync` so the host can
//! collect them into a `Vec<Box<dyn ServiceDescriptor>>` and share across
//! tasks.
//!
//! Test: `service_descriptor_trait_object_dispatches` in `lib.rs` tests
//! verifies trait object dispatch and tool enumeration through a mock impl.
/// Why: single registration contract all services implement to contribute
/// tools to the unified OpenRPC document in the host process.
/// What: trait objects collected at startup, passed to
/// `OpenRpcBuilder::from_services`.
/// Test: tests in `lib.rs` verify trait object dispatch and tool enumeration.