Wiring and checking
The three traits every context's wiring rests on, and the ones a wiring error names.
Overview
In Context-Generic Programming (CGP), wiring a
context, the type the implementation runs against, records
which provider it uses for each component and checks that the provider's own requirements are met. These traits carry that, and you read them far more often than you write them, because a
delegate_components! table generates the first two and a
check_components! block asserts the third.
They build on one another. A context becomes a type-level table through
DelegateComponent, one entry per component. Each entry also carries an
IsProviderFor impl that re-exposes the chosen provider's where bounds, so a
missing dependency is named rather than hidden. CanUseComponent combines the
two into a single question that a check asserts: does the context delegate this component, and do its
provider's requirements hold?
DelegateComponent: the per-context table mapping a component to its provider; what a wiring line becomes.IsProviderFor: the marker that surfaces a provider's missing dependency by name, and the trait a#[check_providers]assertion names.CanUseComponent: the context-side check acheck_components!block reduces to, holding only when a component is both delegated and satisfiable.
The ideas behind them
- Consumer and provider traits: the split this wiring connects.
- Bypassing coherence: why the choice is recorded per context.
- Check traits: why wiring is lazy, and how an assertion makes its failures readable.
An AI agent wrote this page using the CGP knowledge base. Its content was verified against the library's source. See How AI is used in this project.