Five independent example crates, each a small program that shows one area of Context-Generic Programming (CGP) in use.
The crates share a workspace and nothing else. Each one is a demonstration rather than a library, and each is documented on the website, where the code is explained rather than only listed.
Website · CGP quickstart · Project pages · Reference
| Crate | What it shows | Run it |
|---|---|---|
transfer |
A money-transfer HTTP service: an environmental context with one handler dispatched per endpoint, and a namespace-organized wiring table | cargo run -p cgp-example-transfer --bin server |
expression |
An arithmetic interpreter open to new variants and operations: a parameter-targeted component with per-type dispatch | cargo test -p cgp-example-expression |
builder |
An application context assembled from per-subsystem builders | cargo build -p cgp-example-builder |
web-app |
One social-media backend wired four ways, from one trait per domain up to namespace defaults | cargo build -p cgp-example-web-app |
greet |
A greeting written three ways: as a function, as a component, and over an abstract type | cargo run -p cgp-example-greet --bin greet-function |
transfer is the only crate with a README of its own: it is a
walkthrough that teaches the CGP constructs the service uses, and
example.sh shows a session against a running server.
Nothing in web-app or builder runs. Their value is the wiring they compile, so a successful build
is most of their verification, and check_components! blocks check the rest.
Two crates have a page of their own on the website, which explains the code rather than listing it:
expression and
web-app.
The workspace takes cgp and cgp-error-anyhow 0.8.0 from crates.io. To build against a local
change to cgp instead, point both crates at a checkout in ../cgp with a [patch.crates-io]
section in the root Cargo.toml:
[patch.crates-io]
cgp = { path = "../cgp/crates/main/cgp" }
cgp-error-anyhow = { path = "../cgp/crates/standalone/error/cgp-error-anyhow" }It needs stable Rust 1.90 or later and uses the 2024 edition. The only tests in the workspace are
three unit tests in expression; the other crates check their wiring at compile time with
check_components! blocks.
cargo build --workspace
cargo test --workspaceContributors and agents start from AGENTS.md, which names these checks.
The website is the main documentation: the quickstart, the tutorials, the concepts, and the construct reference. The project pages explain these crates, and the CGP knowledge base records each crate in depth for contributors and agents.
sibling-projects.md lists the related repositories.
Licensed under the MIT license.