Expand description
§Reinhardt Apps
Django-inspired application configuration and registry system for Reinhardt.
§Overview
This crate provides the infrastructure for managing Django-style applications in a Reinhardt project. It handles application registration, configuration, model discovery, and lifecycle management.
§Features
AppConfig: Application configuration with metadata and settingsApps: Central registry for all installed applicationsApplicationBuilder: Builder pattern for fluent application construction- Model Discovery: Automatic model and migration discovery via
discoverymodule - Signals: Application lifecycle signals via
signalsmodule - Validation: Registry validation for circular dependencies and duplicates
§Modules
apps: CoreAppConfigandAppsregistrybuilder:ApplicationBuilderfor fluent application constructiondiscovery: Automatic model, migration, and relationship discoveryregistry: Global model and relationship registry (MODELS,RELATIONSHIPS)signals: Application lifecycle signalsvalidation: Registry validation utilities
§Quick Start
ⓘ
use reinhardt_apps::{ApplicationBuilder, AppConfig};
// Build an application with multiple apps
let app = ApplicationBuilder::new()
.add_setting("DEBUG", "true")
.add_app(AppConfig::new("users", "myproject.users"))
.add_app(AppConfig::new("blog", "myproject.blog"))
.build()
.expect("Failed to build application");
// Check if an app is installed
if app.apps_registry().is_installed("users") {
println!("Users app is installed");
}§Model Registry
Models are automatically discovered and registered in the global registry:
ⓘ
use reinhardt_apps::{get_registered_models, find_model};
// Get all registered models
let models = get_registered_models();
// Find a specific model by name
if let Some(user_model) = find_model("User") {
println!("Found User model in app: {}", user_model.app_label);
}§Application Lifecycle
- Configuration: Define
AppConfigfor each application - Registration: Add apps to
ApplicationBuilder - Discovery: Models and migrations are automatically discovered
- Validation: Registry is validated for consistency
- Ready: Application signals are fired when setup is complete
§Re-exports
This crate re-exports commonly used types from other Reinhardt crates:
- From
reinhardt-http:Request,Response,StreamBody - From
reinhardt-conf:Settings,DatabaseConfig,MiddlewareConfig - From
reinhardt-exception:Error,Result - From
reinhardt-server:HttpServer,serve - From
reinhardt-types:Handler,Middleware,MiddlewareChain
Re-exports§
pub use apps::AppCommandConfig;pub use apps::AppConfig;pub use apps::AppError;pub use apps::AppLocaleConfig;pub use apps::AppMediaConfig;pub use apps::AppResult;pub use apps::AppStaticFilesConfig;pub use apps::Apps;pub use apps::BaseCommand;pub use apps::LocaleProvider;pub use apps::MediaProvider;pub use apps::StaticFilesProvider;pub use apps::get_app_commands;pub use apps::get_app_locales;pub use apps::get_app_media;pub use apps::get_app_static_files;pub use builder::Application;pub use builder::ApplicationBuilder;pub use builder::ApplicationDatabaseConfig;pub use builder::BuildError;pub use builder::BuildResult;pub use builder::RouteConfig;pub use registry::MODELS;pub use registry::ModelMetadata;pub use registry::RELATIONSHIPS;pub use registry::RelationshipMetadata;pub use registry::RelationshipType;pub use registry::ReverseRelationMetadata;pub use registry::ReverseRelationType;pub use registry::finalize_reverse_relations;pub use registry::find_model;pub use registry::get_models_for_app;pub use registry::get_registered_models;pub use registry::get_registered_relationships;pub use registry::get_relationships_for_model;pub use registry::get_relationships_to_model;pub use registry::get_reverse_relations_for_model;pub use registry::register_reverse_relation;pub use discovery::MigrationMetadata;pub use discovery::RelationMetadata;pub use discovery::RelationType;pub use discovery::build_reverse_relations;pub use discovery::create_reverse_relation;pub use discovery::discover_all_models;pub use discovery::discover_migrations;pub use discovery::discover_models;pub use validation::ValidationError;pub use validation::ValidationResult;pub use validation::check_circular_relationships;pub use validation::check_duplicate_model_names;pub use validation::check_duplicate_table_names;pub use validation::validate_registry;pub use inventory;
Modules§
- apps
- Application Registry
- builder
- Application builder module
- discovery
- Model and migration discovery
- hooks
- Application lifecycle hooks
- registry
- Global model registry
- signals
- Application lifecycle signals
- validation
- Model registry validation
Macros§
- register_
app_ command - Register a custom management command
- register_
app_ locale - Register locale directory for an application
- register_
app_ media - Register media files directory for an application
- register_
app_ static_ files - Register static files for an application
Structs§
- Database
Config - Database configuration
- Http
Server - HTTP Server with middleware support
- Middleware
Chain - Middleware chain - composes multiple middleware into a single handler.
- Middleware
Config - Middleware configuration
- Request
- HTTP Request representation
- Response
- HTTP Response representation
- Settings
Deprecated - Main settings structure for a Reinhardt project
- Streaming
Response - Streaming HTTP Response
- Template
Config - Template engine configuration
Enums§
- Error
- The main error type for the Reinhardt framework.
Traits§
- Handler
- Handler trait for processing requests.
- Middleware
- Middleware trait for request/response processing.
Functions§
- serve
- Helper function to create and run a server
Type Aliases§
- Result
- A convenient
Resulttype alias usingreinhardt_core::exception::Erroras the error type. - Stream
Body - Type alias for streaming body