Skip to main content

Crate reinhardt_apps

Crate reinhardt_apps 

Source
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 settings
  • Apps: Central registry for all installed applications
  • ApplicationBuilder: Builder pattern for fluent application construction
  • Model Discovery: Automatic model and migration discovery via discovery module
  • Signals: Application lifecycle signals via signals module
  • Validation: Registry validation for circular dependencies and duplicates

§Modules

§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

  1. Configuration: Define AppConfig for each application
  2. Registration: Add apps to ApplicationBuilder
  3. Discovery: Models and migrations are automatically discovered
  4. Validation: Registry is validated for consistency
  5. Ready: Application signals are fired when setup is complete

§Re-exports

This crate re-exports commonly used types from other Reinhardt crates:

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§

DatabaseConfig
Database configuration
HttpServer
HTTP Server with middleware support
MiddlewareChain
Middleware chain - composes multiple middleware into a single handler.
MiddlewareConfig
Middleware configuration
Request
HTTP Request representation
Response
HTTP Response representation
SettingsDeprecated
Main settings structure for a Reinhardt project
StreamingResponse
Streaming HTTP Response
TemplateConfig
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 Result type alias using reinhardt_core::exception::Error as the error type.
StreamBody
Type alias for streaming body