rustf 1.0.0

A simple MVC web framework inspired by Total.js
Documentation

rustf

crates.io docs.rs License: MIT OR Apache-2.0

A convention-based MVC web framework for Rust, inspired by Total.js v4. Designed to be equally intuitive for human developers and AI coding assistants: auto-discovery, predictable patterns, a Total.js-style template engine, sessions, and a multi-database model layer.

Status: 1.0.0-rc1 โ€” release candidate. APIs are close to stable; feedback welcome.

๐Ÿ“– Documentation ยท Repository

Quick start

[dependencies]
rustf = "1.0.0-rc1"
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
use rustf::prelude::*;

#[tokio::main]
async fn main() -> rustf::Result<()> {
    let app = RustF::new()
        .controllers(auto_controllers!())
        .middleware_from(auto_middleware!());
    app.start().await
}
// src/controllers/home.rs
use rustf::prelude::*;

pub fn install() -> Vec<Route> {
    routes![ GET "/" => index ]
}

async fn index(ctx: &mut Context) -> rustf::Result<()> {
    ctx.json(json!({ "status": "ok", "framework": "RustF" }))
}

Highlights

  • Auto-discovery โ€” controllers, models, middleware, workers, events discovered at build time (no mod.rs wiring).
  • Total.js-style views โ€” @{...} template engine with conditionals, loops, sections, layouts, form helpers (@{text}/@{textarea}/@{checkbox}/@{radio}/โ€ฆ), and meta helpers (@{title}/@{description}/@{meta}).
  • Model layer โ€” query builder + BaseModel over PostgreSQL, MySQL/MariaDB and SQLite (via sqlx).
  • Sessions โ€” in-memory by default; Redis-backed for multi-instance/clustered deployments.
  • Security built-in โ€” CSRF, security headers, path-traversal protection, context-aware escaping.

Cargo features (opt-out)

All database drivers and Redis are on by default. For a leaner build, disable defaults and enable only what you need:

rustf = { version = "1.0.0-rc1", default-features = false, features = [
    "embedded-views",
    "db-postgres",   # pulls in `database` + `decimal` automatically
] }
Feature Default Enables
db-postgres / db-mysql / db-sqlite โœ… per-driver SQL support (each implies database)
database โœ… driverless SQL core + decimal
redis โœ… Redis-backed (cross-instance) session storage
embedded-views โœ… compile templates into the binary
schema โ€” YAML schema validation + codegen
cli โ€” clap-based argument parsing

TOML config loading, the auto-discovery macros, and UUID support are core and always compiled.

See the Installation guide for the full table.

License

Licensed under either of Apache License 2.0 or MIT license at your option.