Crate bloom_web

Crate bloom_web 

Source
Expand description

§Bloom Framework

A lightweight backend framework that focuses on developer ergonomics by combining:

  • Actix-Web for high‑performance HTTP
  • SQLx (MySQL) for async, compile‑time checked database access
  • Declarative macros to auto‑register controllers/routes, entities/migrations, and scheduled jobs
  • Inventory-based discovery: drop in code, it self-registers
  • Optional OpenAPI generation and Swagger UI via utoipa
  • Simple, timestamped logging macro
  • Config-first setup using a TOML file (config.toml)

§Quick Start

use bloom::prelude::*;

#[derive(Entity, Serialize, Deserialize)]
#[table("users")]
struct User {
    #[id]
    id: i32,
    #[column("username")]
    username: String,
    #[column("email")]
    email: String,
}

#[repository(User)]
pub struct UserRepository;

#[get_mapping("/users")]
pub async fn get_users() -> impl Responder {
    HttpResponse::Ok().json("Hello from Bloom!")
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    bloom::application::run().await
}

Re-exports§

pub use actix_web;
pub use anyhow;
pub use chrono;
pub use serde_json;
pub use sqlx;
pub use utoipa;

Modules§

actix_web
Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
anyhow
githubcrates-iodocs-rs
application
config
controller_registry
entity_registry
log
A lightweight logging facade.
logger
prelude
Convenience module that re-exports the most commonly used items
scheduler_registry
serde
Serde
serde_json
Serde JSON
sqlx
The async SQL toolkit for Rust, built with ❤️ by the LaunchBadge team.
swagger_registry
tokio
A runtime for writing reliable network applications without compromising speed.
web
Essentials helper functions and types for application registration.

Macros§

logger

Structs§

BloomApp
The main Bloom application that can be run to start the web server.
BloomApplication
Application builder for configuring and creating Bloom applications.
BloomConfig
Configuration settings for the Bloom application.
Controller
A controller registration entry provided by the #[controller] macro.
CorsSettings
Configuration settings for Cross-Origin Resource Sharing (CORS).
HttpResponse
An outgoing response.
Migration
A migration entry registered by each Entity derive.
MySql
MySQL database driver.
PathOperation
Registry for OpenAPI path operations with request schema detection.
Scheduled
A scheduled job registration entry provided by the #[scheduled] macro.
SchemaInfo
Registry for OpenAPI schemas.
ServerRun
Settings
Main application settings loaded from configuration file.

Traits§

Deserialize
A data structure that can be deserialized from any data format supported by Serde.
Responder
Trait implemented by types that can be converted to an HTTP response.
Serialize
A data structure that can be serialized into any data format supported by Serde.

Functions§

_init
Initializes the logger module to ensure proper compilation. This function ensures that the chrono dependency is properly linked even when the logger macro is not used directly in the code.
configure_all
Configures all registered controllers with the provided ServiceConfig.
generate_openapi
Generates OpenAPI document from collected inventory.
run
Creates a new ServerRun instance.
run_all
Runs all registered migrations in sequence.
start_all
Starts all registered scheduled jobs.

Type Aliases§

Pool
An alias for Pool, specialized for MySQL.

Attribute Macros§

auto_register
controller
delete
delete_mapping
get
get_mapping
patch
patch_mapping
post
post_mapping
put
put_mapping
repository
scheduled

Derive Macros§

ApiSchema
Deserialize
Entity
Derives Entity functionality for structs, generating database table creation and CRUD operations.
Serialize