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
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Context-Generic Programming (CGP) core wiring trait.
//!
//! CGP is a type-level composition pattern where a "context" struct maps
//! component names to concrete provider types. The foundational trait is
//! [`HasComponent`], which performs this mapping. The [`delegate_components!`]
//! macro generates bulk implementations.
//!
//! # Example
//!
//! ```rust,ignore
//! // Define component marker types
//! struct ApprovalComponent;
//! struct SandboxComponent;
//!
//! // Wire them for a context
//! delegate_components!(InteractiveCtx {
//! ApprovalComponent => PromptApproval,
//! SandboxComponent => WorkspaceSandbox,
//! });
//!
//! // Access the wired provider type
//! let provider: ComponentProvider<InteractiveCtx, ApprovalComponent> = ...;
//! ```
/// Type-level lookup: maps a component **Name** to a concrete **Provider**
/// type for a given implementor (the "context").
///
/// This is the single foundational trait of the CGP substrate. All
/// composition flows through it.
/// The elaborated provider/dictionary selected by `Ctx` for component `Name`.
pub type ComponentProvider<Ctx, Name> = Provider;
/// Wire multiple component names to provider types for a context.
///
/// Generates one `HasComponent<Name>` implementation per entry.
///
/// ```rust,ignore
/// delegate_components!(MyCtx {
/// ApprovalComponent => PromptApproval,
/// SandboxComponent => WorkspaceSandbox,
/// });
/// ```