Skip to main content

Module registry_table

Module registry_table 

Source
Expand description

Static dispatch table for well-known [Component] impls.

Maps each well-known ComponentId to its zero-sized ErasedComponent impl so dispatch sites can resolve a runtime ComponentId to the right per-component logic without per-call boxing. The table is hand-maintained and sorted by ComponentId::as_u16() so lookup_component does a single binary search.

§Adding a new well-known component

  1. Add a Component impl in app_data::components::*.
  2. Insert a (ComponentId::FOO, &FooComponent) entry into WELL_KNOWN, maintaining ascending sort order.
  3. The compile-time assert_table_is_sorted_and_unique check at the bottom of this file verifies invariants on every build.

Custom (host-registered) components live outside this table — see app_data::custom (added in jj change #14) for the runtime registration path.

Statics§

WELL_KNOWN
Sorted-ascending table of (ComponentId, &dyn ErasedComponent) entries for every well-known XMTP component.

Functions§

lookup_component
Look up the ErasedComponent for a ComponentId.