Skip to main content

Module cgp

Module cgp 

Source
Expand description

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

// 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> = ...;

Traits§

HasComponent
Type-level lookup: maps a component Name to a concrete Provider type for a given implementor (the “context”).

Type Aliases§

ComponentProvider
The elaborated provider/dictionary selected by Ctx for component Name.