Skip to main content

Crate rainier

Crate rainier 

Source
Expand description

Rainier — a batteries-included MVC framework for Rust.

use rainier::prelude::*;

async fn index() -> &'static str {
    "Hello from Rainier"
}

let app = Rainier::new(".")
    .with_routes(|router| {
        router.get("/", index).name("home");
    })
    .boot()
    .await?;

§This crate is a name

Everything here is rainier-framework, re-exported. The two are the same crate for every purpose except the line in your Cargo.toml, and they are versioned together — rainier 1.2.3 is rainier-framework 1.2.3 and nothing else.

Depend on whichever reads better. rainier is shorter and makes use rainier::prelude::* the obvious first line; rainier-framework says what it is next to the twenty-odd rainier-* crates it is assembled from.

§Where to start

prelude has what an application uses constantly. The documentation is one page per concept, and each page explains the design decisions other MVC frameworks leave implicit — including the places Rainier deliberately disagrees with them.

Modules§

auth
rainier-auth
binding
Route-model binding — an action parameter that is the looked-up model rather than its id.
bootstrap
Bootstrapping — Rainier, the builder that assembles an application.
broadcast
Broadcasting — an event pushed to a browser, and the authorisation that decides who may listen.
broadcasting
The half of broadcasting that needs HTTP: the authorisation endpoint, the socket header, and the notification channel.
cache
rainier-cache
commands
The commands Rainier ships — route:list, serve, migrate, queue:work, key:generate.
config
rainier-config
console_kernel
rainier-console
container
rainier-container
crypt
rainier-crypt
database
rainier-database
drivers
rainier-drivers
events
rainier-events
facades
The facades — static proxies onto container-resolved services.
filesystem
rainier-filesystem
groups
The middleware groups Rainier ships — web and api, as functions rather than as keys in a map.
health
Health checks — Health and the endpoint that renders them.
http
rainier-http
http_client
rainier-http-client
keys
The configuration keys Rainier itself reads — a typed index of the tree.
limits
Rate limits that survive a second replica — RateLimits and shared.
mail
rainier-mail
metrics
Prometheus metrics — a registry, the text format, and request instrumentation.
middleware
rainier-middleware
notifications
The notification channel that needs a database.
notify
rainier-notify
observability
Metrics, tracing and the OpenAPI document, built from configuration.
openapi
An OpenAPI 3.1 document, built from the router and the request contracts.
prelude
Everything an application file usually wants in scope.
queue
rainier-queue
queued_listeners
Listeners that go on the queue — DispatcherExt and FromEvent.
routing
rainier-routing
scheduler
rainier-scheduler
scheduling
Scheduling — the tasks and commands that need more than the scheduler crate depends on.
server
rainier-server
session
rainier-session
signed
Signed routes — SignedUrls and ValidateSignature.
support
rainier-support
telemetry
OpenTelemetry — trace context in, spans out.
testing
A test harness — TestApp and TestResponse.
validation
rainier-validation
view
rainier-view
websocket
WebSockets — a connection that stays open, served alongside HTTP.

Macros§

bind_executor
Writes the Connection impl for a concrete Rainier ORM Executor.
facade
Declare a facade type and its Facade impl.
param_key
Declare a route-parameter name for BoundAs.

Structs§

Application
The application: a Container with a boot lifecycle, an environment, and a filesystem layout.
CommandTask
A Task that runs a console command.
Health
A registry of health checks.
HealthReport
The whole report.
JobTask
A Task that dispatches a queued job.
KeyGenerateCommand
key:generate — mint an application key.
MigrateCommand
migrate — run pending migrations.
MigrateRollbackCommand
migrate:rollback — undo the most recent batch of migrations.
QueueWorkCommand
queue:work — process queued jobs.
Rainier
Assembles an Application.
RateLimits
The store every shared limiter in this application counts in.
RouteListCommand
route:list — print the route table.
ScheduleListCommand
schedule:list — what is scheduled, and when it next runs.
ScheduleRunCommand
schedule:run — run whatever is due this minute, then exit.
ScheduleWorkCommand
schedule:work — the same thing in a loop, for a container.
ServeCommand
serve — run the HTTP server.
SignedUrls
Signed URLs for this application’s named routes.
TestApp
A booted application, ready to be asked for responses.
TestResponse
One response, with its body already read.
ValidateSignature
Refuses a request whose URL is not signed by this application.
Views
The application’s view engine, as a container-storable value.

Traits§

DispatcherExt
listen_queued, on top of Dispatcher.
Facade
A static proxy onto a container-resolved service.
FromEvent
A job that can be built from an event.
ScheduleExt
job and command, on top of Schedule.
ServiceProvider
A bundle of related bindings and their boot-time wiring.

Functions§

console
A console with every built-in command registered.