Rullst Specification πŸ“„

"The Single Source of Truth (SST) for Framework Architecture & Conventions"

This document is the Single Source of Truth (SST) for the Rullst Framework. It specifies the exact conventions, API structures, naming rules, and directory standards of Rullst.

[!IMPORTANT] AI Alignment Instruction: Whenever updating, refactoring, or generating documentation and code for Rullst, always refer to this specification as the baseline. Do not invent or assume conventions outside of this document.


πŸ“‚ 1. Directory Structure Conventions

A standard Rullst application scaffold must strictly follow this folder hierarchy:

my-app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ controllers/      # Route controllers (async modules)
β”‚   β”‚   └── mod.rs
β”‚   β”œβ”€β”€ models/           # Active Record Models (rust-eloquent entities)
β”‚   β”‚   └── mod.rs
β”‚   β”œβ”€β”€ pages/            # Shared static HTML elements or full page layouts
β”‚   β”‚   └── mod.rs
β”‚   └── main.rs           # Entrypoint, DB initialization, and Central routing
β”œβ”€β”€ Cargo.toml            # Project cargo dependencies
└── Rullst.toml           # Framework configuration (databases, environment, etc.)

πŸ› οΈ 2. Naming Conventions

To guarantee consistency, both humans and AI coders must adhere to the following name normalization rules handled by the cargo-rullst generator:


⚑ 3. Core API Specifications

3.1. Server & Routing (rullst::routing)

3.2. Server-Side Rendering (rullst::macros)

3.3. Active Record ORM (rust-eloquent)


πŸ’» 4. CLI Specifications (cargo-rullst)


🧱 5. Controller Architecture

Controllers handle business logic and HTTP responses.


πŸ“„ 6. HTML Pages & Components

Rullst uses a functional approach for HTML rendering, relying on the html! macro.


🚨 7. Error Handling

Consistent error handling ensures safety and predictable API responses.


πŸ›‘οΈ 8. Middlewares

Middlewares intercept requests for authentication, logging, etc.


πŸ›‘οΈ 9. Architectural Guidelines for Backward Compatibility

To guarantee stress-free and self-healing updates for Rullst users, all framework code must strictly adhere to the following backward compatibility rules:

9.1. The Builder Pattern and #[non_exhaustive]

Any public configuration struct or extensible enum exposed by the framework must use the #[non_exhaustive] attribute. This prevents developers from instantiating the struct directly, ensuring that adding new fields in future minor versions will not break user code.

#[non_exhaustive]
pub struct RullstConfig {
    pub port: u16,
}

impl RullstConfig {
    pub fn new(port: u16) -> Self {
        Self { port }
    }
}

9.2. Deprecation Lifecycle (#[deprecated])

The framework will never abruptly remove or rename a public function, struct, or method. If a breaking change to an API is required, the old API must be kept alive for at least one minor version using the #[deprecated] attribute.

#[deprecated(since = "0.2.0", note = "Please use `Router::new()` instead")]
pub fn old_initializer() {
    Router::new();
}

9.3. Sealed Traits

If the framework exposes a Trait that is meant to be used by the user but not implemented by the user (e.g., core framework behavior), it must use the "Sealed Trait" pattern. This ensures that adding new methods to the trait in the future will not break downstream implementations.

mod private {
    pub trait Sealed {}
}

pub trait RullstTrait: private::Sealed {
    fn execute(&self);
}