rustclamp 1.0.0

A minimal synchronous entrypoint for Clamp applications.
docs.rs failed to build rustclamp-1.0.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: rustclamp-0.0.0

RustClamp

RustClamp is the application composition layer for Rust. It sits above the crates you already use (Axum and Tower, SQLx, Tokio, NATS) and composes them into one application: modules, typed capabilities, lifecycle and processes. It does not replace them. This is the main repository: the rustclamp facade crate, the clamp developer tool, examples and architecture decisions. The component crates live in their own repositories (see Components).

The facade starts small. With no features it has no dependencies and one entrypoint:

use rustclamp::prelude::*;

fn main() {
    Clamp::run(|| {
        println!("Hello Clamp");
    });
}

Clamp::run calls the closure once on the current thread and returns its result unchanged. Errors and panics keep ordinary Rust behavior. Everything else is an optional feature you turn on.

Quick start

Install the clamp tool and create a project:

curl -fsSL https://rustclamp.com/install.sh | sh   # or: cargo install --path tooling
clamp init my-app --web                             # also: --blank, --app, --vue, --react, --tui, --package, --profile
cd my-app
clamp dev

--web creates a std-only HTTP server with a Laravel-style app/ layout and a Vite+ and Tailwind 4 frontend (needs Node/npm). --vue and --react mount components on server-rendered pages. --package creates a reusable web package (ADR 0008). --profile cli,service,worker combines presets for a kind of software into one binary (ADR 0032). See tooling/README.md for every command, including clamp make:controller, clamp make:migration, clamp migrate and clamp inspect.

To use the facade directly, add it from crates.io and pick features:

[dependencies]
rustclamp = { version = "1", features = ["web", "db"] }

Rust 1.96.1 is the tested minimum (edition 2024). Run the smallest example with cargo run --offline --example 00-pico.

Features

All modules are opt-in Cargo features. Unsafe code is forbidden.

Feature Module What it gives you
config rustclamp::config .env and environment configuration
log rustclamp::log Leveled logging with single, daily, stderr and stack channels
time rustclamp::time UTC dates and times on SystemTime, RFC 3339 parse/format, no time crate
uuid rustclamp::uuid UUID v4 and v7; v7 comes from rustclamp_core::Reference (ADR 0021)
storage rustclamp::storage Named file disks (local, public) that refuse paths leaving the disk
crypto rustclamp::crypto Password hashing, encryption, SHA-256/HMAC, random bytes (ADR 0010)
db rustclamp::db Bundled SQLite: migrations, seeders, Schema builder, table(..) query builder, Db::transaction, States, #[derive(Model)] (ADR 0009, 0014)
web rustclamp::web std-only HTTP server: routing, sessions, CSRF, validation, uploads, Blade-style views, problem+json errors, graceful serve_until, web::testing::Client (ADR 0007, 0012)
auth rustclamp::web::auth Login, roles, email verification and password reset (ADR 0013, 0016)
mail rustclamp::mail SMTP with STARTTLS over rustls, queued through a mail_outbox table (ADR 0015)
queue rustclamp::queue Background jobs by name: request.queue().dispatch(..), retries with backoff, failed_jobs (queue:retry, queue:forget), a jobs table or Redis, queue:work (ADR 0019)
schedule rustclamp::schedule Scheduled tasks in UTC (EveryMinutes, Hourly, Daily, Weekly), schedule:run for cron, once per minute across processes (ADR 0035)
markdown rustclamp::web::markdown Markdown to HTML that escapes raw HTML and unsafe links
regex rustclamp::web::Patterns regex:NAME validation rule with linear-time patterns (ADR 0033)
cache rustclamp::cache Bounded in-process cache with LRU eviction and optional TTL
metrics rustclamp::metrics Counters and gauges with a Prometheus text renderer; Router::metrics serves them
build rustclamp::build build.rs helpers such as build::database

rustclamp::error is always available: the ExitError trait and error::run / error::run_json print an error and exit with its code.

Some ADRs are still proposed. Bearer API tokens (Auth::issue_token, the bearer middleware) are implemented, but ADR 0023 is not yet accepted, and neither are ADRs 0021, 0022 and 0026. The CHANGELOG lists what has landed, including breaking changes to views and Db::transaction.

Components

Applications compose modules through typed capabilities and contributions. Kernel resolves a process projection from selected roots; a runtime drives the work. The composition model is still prototype-stage, and the examples show each step: see the examples for the learning path and the architecture track.

Repository Responsibility
core Shared, domain-neutral contracts: capabilities, modules, contributions, identities, Reference
kernel Composition and resolution of typed requirements and contributions
runtime Executor-neutral task supervision; optional Tokio adapter
http Optional Axum and Tower integration for HTTP interfaces
messaging Versioned message envelope contracts
worker Message handler contributions and routing for workers
scheduler Contribution target for bounded, clock-driven jobs
postgres Optional SQLx PostgreSQL pool and transaction integration

Development

cargo fmt --all -- --check
cargo clippy --offline --locked --all-targets --all-features -- -D warnings
cargo test --offline --locked --all-features
RUSTDOCFLAGS="-D warnings" cargo doc --offline --locked --no-deps --all-features

Measurements and their limitations are in docs/evidence. For the coordinated checkout, architecture checks and release policy, see CONTRIBUTING.md. Documentation lives at docs.rustclamp.com.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option (ADR 0011). Unless you state otherwise, any contribution you submit for inclusion is dual licensed as above, without additional terms or conditions.