Skip to main content

Module custom

Module custom 

Source
Expand description

Host-defined (“custom”) component registration.

Custom components live in the app range (0xC000-0xFEFF, per ComponentId::is_app_range) and are registered by host apps at process startup. Unlike well-known components — which have static Component impls with const ID: ComponentId — a RuntimeComponent carries its id as a runtime value so a host can register multiple distinct components from one impl type parameterized by id (or build them dynamically).

§Lifecycle

  1. Process startup (host): the host calls register_global_runtime_component for each component it wants to support. The registry stores a &'static dyn ErasedComponent-shaped handle keyed by ComponentId.
  2. Dispatch lookup: callers of super::registry_table::lookup_component check the static WELL_KNOWN table first; if no entry exists there and the id is in the app range, the runtime registry is consulted.
  3. Per-group registration: registering a custom component in a group’s COMPONENT_REGISTRY happens via IntentKind::UpdatePermission (post-bootstrap), separately from the host-process registration here. Both must happen before a group can carry a custom component’s value: the host needs a RuntimeComponent impl to decode the bytes, and the group needs a registry entry so writes pass validate_component_write.

§Why a global rather than per-Client

Threading a per-Client registry through every dispatch site (apply_app_data_update_payload, expand_app_data_update_to_changes, validate_component_write, the facade) would touch ~dozens of call shapes. A process-global registry keeps the dispatch signature stable and reflects the operational reality: hosts register their custom-component shapes once, at process startup, before any group is created. There is no use case for “different Clients in the same process know different custom components.”

Enums§

RuntimeRegistrationError
Errors surfaced by register_global_runtime_component.

Traits§

RuntimeComponent
A host-defined component whose ComponentId is known at runtime.

Functions§

register_global_runtime_component
Register a host-defined runtime component.