Cinderblock
A declarative, resource-oriented application framework for Rust.
Define your domain model once using the resource! macro and Cinderblock generates the struct, CRUD operations, persistence layer, and REST API endpoints.
Quick Example
use ;
use Uuid;
resource!
This single declaration generates:
- A
Ticketstruct with serialization - Typed action markers (
Open,Assign,Close,Remove) with dedicated input structs Create,Update, andDestroytrait implementations- REST API endpoints via Axum with OpenAPI documentation
- SQL persistence via SQLx with parameterized queries
Key Concepts
Named Actions
Actions are not generic CRUD verbs -- they are domain-specific operations with their own types and input validation:
.await?;
.await?;
.await?;
Actions can restrict which fields they accept (accept [field1, field2]) and apply programmatic mutations via change_ref closures.
Pluggable Data Layers
- InMemoryDataLayer (default) -- global
RwLock<HashMap>for prototyping - SqliteDataLayer (via
cinderblock-sqlx) -- full SQLite persistence using SQLx
Extension System
Extensions hook into the resource! macro to generate additional code:
extensions
Crates
| Crate | Description |
|---|---|
cinderblock-core |
Resource trait, CRUD functions, Context, in-memory data layer |
cinderblock-core-macros |
The resource! proc macro |
cinderblock-extension-api |
Shared DSL parser types for extension authors |
cinderblock-json-api |
JSON REST API extension (Axum router, OpenAPI, Swagger UI) |
cinderblock-json-api-macros |
JSON API extension proc macro |
cinderblock-sqlx |
SQLx data layer extension (SQLite) |
cinderblock-sqlx-macros |
SQLx extension proc macro |
Running the Examples
# Core CRUD with in-memory storage
# JSON API server with Swagger UI
The API example starts a server on http://localhost:3000 with endpoints like:
GET /helpdesk/support/ticket
POST /helpdesk/support/ticket/open
PATCH /helpdesk/support/ticket/{id}/close
DELETE /helpdesk/support/ticket/{id}/remove
GET /openapi.json
Status
Early development (0.1.0). The API is not stable.
License
Licensed under Apache-2.0.