The RASR-stack is a 100% Rust-native web-framework inspired by the LAMP stack. RASR stands for:
- Redox: A Rust-native operating system.
- Actix: A powerful Rust-native web framework (alternatively, Rocket).
- SurrealDB: A scalable, multi-model database supporting relational semantics, written in Rust.
- Rust: The programming language used throughout the stack.
This stack aims to provide a high-performance, memory-safe alternative to traditional stacks like LAMP.
Follow these steps to set up and run your RASR-Stack application.
Ensure you have the following installed on your system:
- Rust: Install Rust from rust-lang.org.
- Redox OS: (Optional) If you prefer to use Redox OS, follow the Redox installation guide.
- Docker: For containerizing the database (optional).
-
Create a new Rust project:
cargo new my_rasr_project cd my_rasr_project
-
Add the necessary dependencies to your
Cargo.toml
:[dependencies] actix-web = "4" surrealdb = "0.1"
If you prefer Rocket, replace
actix-web
withrocket
:[dependencies] rocket = "0.5.0-rc.2" surrealdb = "0.1"
You can run SurrealDB using Docker:
docker run --rm -p 8000:8000 surrealdb/surrealdb:latest start --log debug
Alternatively, download SurrealDB from the official website and run it directly.
Create a simple Actix web server that connects to SurrealDB.
use actix_web::{web, App, HttpServer, Responder};
use surrealdb::Surreal;
use surrealdb::sql::Value;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let db = Surreal::new("http://localhost:8000").await.unwrap();
HttpServer::new(move || {
App::new()
.data(db.clone())
.route("/", web::get().to(index))
})
.bind("127.0.0.1:8080")?
.run()
.await
}
async fn index(db: web::Data<Surreal<surrealdb::http::Client>>) -> impl Responder {
let response: Value = db.query("SELECT * FROM my_table").await.unwrap();
format!("Hello from RASR-Stack! Data: {:?}", response)
}
Run your application with:
cargo run
Visit http://127.0.0.1:8080
in your web browser to see your running application.
Feel free to open issues or submit pull requests if you have suggestions for improvements or find any bugs.
This project is licensed under the Apache License - see the LICENSE file for details.
Happy coding with the RASR-Stack! 🚀