Skip to main content

reinhardt/
lib.rs

1// The `User` trait is deprecated in favour of the new `#[model]`-based user macro system.
2// This crate re-exports it for downstream compatibility during the transition period.
3#![allow(deprecated)]
4
5//! # Reinhardt
6//!
7//! A full-stack API framework for Rust, inspired by Django and Django REST Framework.
8//!
9//! Reinhardt provides a complete, batteries-included solution for building production-ready
10//! REST APIs with Rust. It follows Rust's composition patterns instead of Python's inheritance
11//! model, making full use of traits, generics, and zero-cost abstractions.
12//!
13//! ## Core Principles
14//!
15//! - **Composition over Inheritance**: Uses Rust's trait system for composable behavior
16//! - **Type Safety**: Leverages Rust's type system for compile-time guarantees
17//! - **Zero-Cost Abstractions**: High-level ergonomics without runtime overhead
18//! - **Async-First**: Built on tokio and async/await from the ground up
19//!
20//! ## Feature Flags
21//!
22//! Reinhardt provides flexible feature flags to control compilation and reduce binary size.
23//!
24//! ### Presets
25//!
26//! - `minimal` - Core functionality only (routing, DI, params)
27//! - `full` (default) - All features enabled
28//! - `standard` - Balanced for most projects
29//! - `api-only` - REST API without templates/forms
30//! - `graphql-server` - GraphQL-focused setup
31//! - `websocket-server` - WebSocket-centric setup
32//! - `cli-tools` - CLI and background jobs
33//! - `test-utils` - Testing utilities
34//!
35//! ### Fine-grained Control
36//!
37//! Fine-grained feature flags for precise control over included functionality:
38//!
39//! #### Authentication ✅
40//! - `auth-jwt` - JWT authentication
41//! - `auth-session` - Session-based authentication
42//! - `auth-oauth` - OAuth2 support
43//! - `auth-token` - Token authentication
44//!
45//! #### Database Backends ✅
46//! - `db-postgres` - PostgreSQL support
47//! - `db-mysql` - MySQL support
48//! - `db-sqlite` - SQLite support
49//! - `db-cockroachdb` - CockroachDB support (distributed transactions)
50//!
51//! #### Middleware ✅
52//! - `middleware-cors` - CORS (Cross-Origin Resource Sharing) middleware
53//! - `middleware-compression` - Response compression (Gzip, Brotli)
54//! - `middleware-security` - Security headers (HSTS, XSS Protection, etc.)
55//! - `middleware-rate-limit` - Rate limiting and throttling
56//!
57//! See [Cargo.toml feature definitions](https://github.com/kent8192/reinhardt/blob/main/Cargo.toml) for detailed documentation.
58//!
59//! ## Quick Example
60//!
61//! ```rust,ignore
62//! use reinhardt::prelude::*;
63//! use serde::{Serialize, Deserialize};
64//! use std::sync::Arc;
65//!
66//! // Define your model (using composition, not inheritance)
67//! #[derive(Debug, Clone, Serialize, Deserialize)]
68//! struct User {
69//!     id: Option<i64>,
70//!     username: String,
71//!     email: String,
72//! }
73//!
74//! // Implement Model trait
75//! impl Model for User {
76//!     type PrimaryKey = i64;
77//!     fn table_name() -> &'static str { "users" }
78//!     fn primary_key(&self) -> Option<&Self::PrimaryKey> { self.id.as_ref() }
79//!     fn set_primary_key(&mut self, value: Self::PrimaryKey) { self.id = Some(value); }
80//! }
81//!
82//! // Create a ViewSet (no inheritance needed!)
83//! let users_viewset = ModelViewSet::<User, JsonSerializer<User>>::new("users");
84//!
85//! // Set up routing
86//! let mut router = DefaultRouter::new();
87//! router.register_viewset("users", users_viewset);
88//!
89//! // Add middleware using composition
90//! let app = MiddlewareChain::new(Arc::new(router))
91//!     .with_middleware(Arc::new(LoggingMiddleware::new()))
92//!     .with_middleware(Arc::new(CorsMiddleware::permissive()));
93//! ```
94
95#![cfg_attr(docsrs, feature(doc_cfg))]
96
97// Re-export external crates for macro support
98// Macro-generated code uses paths like `::reinhardt::reinhardt_apps::AppConfig`
99// These wrapper modules provide the namespace structure that macros expect.
100// Note: These are marked #[doc(hidden)] because they are internal dependencies
101// used by macro-generated code. Users should not use these directly.
102
103// WASM-compatible re-exports (always available)
104#[cfg(feature = "pages")]
105#[doc(hidden)]
106pub mod reinhardt_pages {
107	pub use reinhardt_pages::*;
108}
109
110#[doc(hidden)]
111pub mod reinhardt_types {
112	// Public API surface glob re-export requires allowing unused imports and unreachable pub
113	#[allow(unused_imports, unreachable_pub)]
114	pub use reinhardt_core::types::*;
115}
116
117// Server-side only re-exports (NOT for WASM)
118#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
119#[doc(hidden)]
120pub mod reinhardt_apps {
121	pub use reinhardt_apps::*;
122}
123
124#[cfg(all(feature = "di", not(target_arch = "wasm32")))]
125#[doc(hidden)]
126pub mod reinhardt_di {
127	pub use reinhardt_di::*;
128}
129
130#[cfg(all(feature = "auth", not(target_arch = "wasm32")))]
131#[doc(hidden)]
132pub mod reinhardt_auth {
133	pub use reinhardt_auth::*;
134}
135
136#[cfg(not(target_arch = "wasm32"))]
137#[doc(hidden)]
138pub mod reinhardt_core {
139	pub use reinhardt_core::*;
140	// For macro compatibility: Re-export EndpointMetadata at module level
141	pub use reinhardt_core::endpoint::EndpointMetadata;
142}
143
144#[cfg(not(target_arch = "wasm32"))]
145#[doc(hidden)]
146pub mod reinhardt_http {
147	pub use reinhardt_http::*;
148}
149
150#[cfg(all(feature = "di", not(target_arch = "wasm32")))]
151#[doc(hidden)]
152pub mod reinhardt_params {
153	pub use reinhardt_di::params::*;
154}
155
156#[cfg(not(target_arch = "wasm32"))]
157#[doc(hidden)]
158pub mod async_trait {
159	pub use async_trait::*;
160}
161
162#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
163#[doc(hidden)]
164pub mod linkme {
165	pub use linkme::*;
166}
167
168#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
169#[doc(hidden)]
170pub mod ctor {
171	pub use ctor::*;
172}
173
174#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
175#[doc(hidden)]
176pub mod reinhardt_orm {
177	pub use reinhardt_db::orm::*;
178}
179
180// Module re-exports following Django's structure
181// WASM-compatible modules (always available)
182#[cfg(feature = "pages")]
183pub mod pages;
184
185// Server-side only modules (NOT for WASM)
186#[cfg(all(feature = "admin", not(target_arch = "wasm32")))]
187pub mod admin;
188#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
189pub mod apps;
190#[cfg(all(feature = "commands", not(target_arch = "wasm32")))]
191pub mod commands;
192#[cfg(all(feature = "conf", not(target_arch = "wasm32")))]
193pub mod conf;
194#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
195pub mod core;
196#[cfg(all(feature = "deeplink", not(target_arch = "wasm32")))]
197pub mod deeplink;
198#[cfg(all(feature = "dentdelion", not(target_arch = "wasm32")))]
199pub mod dentdelion;
200#[cfg(all(feature = "di", not(target_arch = "wasm32")))]
201pub mod di;
202#[cfg(all(feature = "dispatch", not(target_arch = "wasm32")))]
203pub mod dispatch;
204#[cfg(all(feature = "forms", not(target_arch = "wasm32")))]
205pub mod forms;
206#[cfg(all(feature = "graphql", not(target_arch = "wasm32")))]
207pub mod graphql;
208#[cfg(all(feature = "grpc", not(target_arch = "wasm32")))]
209pub mod grpc;
210#[cfg(not(target_arch = "wasm32"))]
211pub mod http;
212#[cfg(all(feature = "i18n", not(target_arch = "wasm32")))]
213pub mod i18n;
214#[cfg(all(feature = "mail", not(target_arch = "wasm32")))]
215pub mod mail;
216#[cfg(all(
217	any(feature = "standard", feature = "middleware"),
218	not(target_arch = "wasm32")
219))]
220pub mod middleware;
221#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
222pub mod rest;
223#[cfg(all(feature = "server", not(target_arch = "wasm32")))]
224pub mod server;
225#[cfg(all(feature = "shortcuts", not(target_arch = "wasm32")))]
226pub mod shortcuts;
227#[cfg(all(feature = "tasks", not(target_arch = "wasm32")))]
228pub mod tasks;
229#[cfg(all(feature = "templates", not(target_arch = "wasm32")))]
230pub mod template;
231#[cfg(all(feature = "test", not(target_arch = "wasm32")))]
232pub mod test;
233#[cfg(not(target_arch = "wasm32"))]
234pub mod urls;
235#[cfg(not(target_arch = "wasm32"))]
236pub mod utils;
237#[cfg(not(target_arch = "wasm32"))]
238pub mod views;
239
240// Server-side only re-exports (NOT for WASM)
241// Re-export app types from reinhardt-apps
242#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
243pub use reinhardt_apps::{AppConfig, AppError, AppResult, Apps};
244
245// Re-export macros
246#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
247pub use reinhardt_macros::{AppConfig, app_config, installed_apps};
248
249// Re-export settings attribute macro (requires conf feature)
250#[cfg(all(feature = "conf", not(target_arch = "wasm32")))]
251pub use reinhardt_macros::settings;
252
253// Re-export Model derive macro and model attribute macro (requires database feature)
254#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
255pub use reinhardt_macros::{Model, model};
256
257// Re-export collect_migrations macro (requires database feature)
258#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
259pub use reinhardt_macros::collect_migrations;
260
261// Re-export reinhardt_migrations crate (used by collect_migrations! macro)
262#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
263pub use reinhardt_db::migrations;
264
265// Alias for macro compatibility
266#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
267#[doc(hidden)]
268pub use migrations as reinhardt_migrations;
269
270// Re-export reinhardt_macros as a module for hierarchical imports
271// This allows macro-generated code to use ::reinhardt::macros::Model
272#[cfg(not(target_arch = "wasm32"))]
273#[doc(hidden)]
274pub mod macros {
275	pub use reinhardt_macros::*;
276}
277
278// Re-export HTTP method macros
279#[cfg(not(target_arch = "wasm32"))]
280pub use reinhardt_macros::{api_view, delete, get, patch, post, put};
281
282// Re-export routes attribute macro for URL pattern registration
283#[cfg(not(target_arch = "wasm32"))]
284pub use reinhardt_macros::routes;
285
286// Re-export admin attribute macro (requires admin feature)
287#[cfg(all(feature = "admin", not(target_arch = "wasm32")))]
288pub use reinhardt_macros::admin;
289
290// Re-export settings from dedicated crate
291#[cfg(all(feature = "conf", not(target_arch = "wasm32")))]
292#[allow(deprecated)]
293// Re-exports deprecated Settings and AdvancedSettings for backward compatibility
294pub use reinhardt_conf::settings::{
295	AdvancedSettings, CacheSettings, CorsSettings, DatabaseConfig, EmailSettings, LoggingSettings,
296	MediaSettings, MiddlewareConfig, SessionSettings, Settings, SettingsError, StaticSettings,
297	TemplateConfig,
298};
299
300#[cfg(all(feature = "conf", not(target_arch = "wasm32")))]
301pub use reinhardt_conf::settings::core_settings::{CoreSettings, HasCoreSettings};
302
303#[cfg(all(feature = "conf", not(target_arch = "wasm32")))]
304pub use reinhardt_conf::settings::fragment::SettingsFragment;
305
306#[cfg(all(feature = "conf", not(target_arch = "wasm32")))]
307pub use reinhardt_conf::settings::fragment::HasSettings;
308
309#[cfg(all(feature = "conf", not(target_arch = "wasm32")))]
310pub use reinhardt_conf::settings::builder::SettingsBuilder;
311
312#[cfg(all(feature = "conf", not(target_arch = "wasm32")))]
313pub use reinhardt_conf::settings::profile::Profile;
314
315#[cfg(all(feature = "conf", not(target_arch = "wasm32")))]
316pub use reinhardt_conf::settings::sources::{
317	DefaultSource, EnvSource, LowPriorityEnvSource, TomlFileSource,
318};
319
320// Re-export ApplyUpdate trait and macros
321pub use reinhardt_core::apply_update::ApplyUpdate;
322#[cfg(not(target_arch = "wasm32"))]
323pub use reinhardt_macros::{ApplyUpdate as DeriveApplyUpdate, apply_update};
324
325// Re-export core types
326#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
327pub use reinhardt_core::{
328	endpoint::EndpointMetadata,
329	exception::{Error, Result},
330};
331
332// Re-export HTTP types
333#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
334pub use reinhardt_http::{Handler, Middleware, MiddlewareChain, Request, Response, ViewResult};
335
336// Re-export inventory crate (used by HTTP method macros for endpoint registration)
337#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
338#[doc(hidden)]
339pub use inventory;
340
341// Re-export ORM
342#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
343pub use reinhardt_db::orm::{
344	DatabaseBackend, DatabaseConnection, Model, QuerySet, SoftDeletable, SoftDelete, Timestamped,
345	Timestamps,
346};
347
348// Re-export ORM query expressions (Django-style F/Q objects)
349//
350// # Availability
351//
352// Requires `database` feature.
353//
354// # Examples
355//
356// ```rust,no_run
357// # use reinhardt::{F, Q};
358// // Reference a field (like Django's F object)
359// let price_expr = F::field("price");
360//
361// // Build complex queries (like Django's Q object)
362// let filter = Q::and(vec![
363//     Q::field("status").equals("active"),
364//     Q::field("price").gt(100),
365// ]);
366// ```
367#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
368pub use reinhardt_db::orm::{
369	// Query expressions (equivalent to Django's F and Q)
370	Exists,
371	F,
372	FieldRef,
373	// Query filter types
374	Filter,
375	FilterOperator,
376	FilterValue,
377	OuterRef,
378	Q,
379	QOperator,
380	Subquery,
381};
382
383// Re-export ORM annotations and aggregations
384//
385// # Availability
386//
387// Requires `database` feature.
388//
389// # Examples
390//
391// ```rust,no_run
392// # use reinhardt::{Annotation, Aggregate, F};
393// # struct User;
394// # impl User { fn objects() -> QueryBuilder { QueryBuilder } }
395// # struct Product;
396// # impl Product { fn objects() -> QueryBuilder { QueryBuilder } }
397// # struct QueryBuilder;
398// # impl QueryBuilder {
399// #     fn annotate(self, _name: &str, _val: Annotation) -> Self { self }
400// #     fn aggregate(self, _name: &str, _val: Aggregate) -> Self { self }
401// # }
402// // Annotate query results with computed values
403// let query = User::objects()
404//     .annotate("full_name", Annotation::concat(vec![
405//         F::field("first_name"),
406//         F::value(" "),
407//         F::field("last_name"),
408//     ]));
409//
410// // Aggregate data
411// let stats = Product::objects()
412//     .aggregate("avg_price", Aggregate::avg("price"));
413// ```
414#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
415pub use reinhardt_db::orm::{
416	// Aggregations
417	Aggregate,
418	AggregateFunc,
419	AggregateValue,
420	// Annotations
421	Annotation,
422	AnnotationValue,
423};
424
425// Re-export ORM transactions
426//
427// # Availability
428//
429// Requires `database` feature.
430//
431// # Examples
432//
433// ```rust,no_run
434// # use reinhardt::{atomic, IsolationLevel, atomic_with_isolation};
435// # #[tokio::main]
436// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
437// # struct User;
438// # struct Profile;
439// # let data = ();
440// // Use atomic decorator for transactions
441// // let result = atomic(|| async {
442// //     let user = User::create(data).await?;
443// //     let profile = Profile::create(user.id).await?;
444// //     Ok((user, profile))
445// // }).await?;
446//
447// // Or with specific isolation level
448// // let result = atomic_with_isolation(IsolationLevel::Serializable, || async {
449// //     // Your transaction code
450// // }).await?;
451// # Ok(())
452// # }
453// ```
454#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
455pub use reinhardt_db::orm::{
456	// Transaction management
457	IsolationLevel,
458	QueryValue,
459	Savepoint,
460	Transaction,
461	TransactionExecutor,
462	TransactionScope,
463	atomic,
464	atomic_with_isolation,
465};
466
467// Re-export ORM database functions
468//
469// # Availability
470//
471// Requires `database` feature.
472//
473// # Examples
474//
475// ```rust,no_run
476// # use reinhardt::{Concat, Upper, Lower, Now, F, Q};
477// # struct User;
478// # impl User { fn objects() -> QueryBuilder { QueryBuilder } }
479// # struct QueryBuilder;
480// # impl QueryBuilder {
481// #     fn annotate(self, _name: &str, _val: impl std::any::Any) -> Self { self }
482// #     fn filter(self, _q: impl std::any::Any) -> Self { self }
483// # }
484// // String functions
485// let query = User::objects()
486//     .annotate("full_name", Concat::new(vec![
487//         F::field("first_name"),
488//         F::value(" "),
489//         F::field("last_name"),
490//     ]))
491//     .annotate("email_upper", Upper::new(F::field("email")));
492//
493// // Date/time functions
494// let recent_users = User::objects()
495//     .filter(Q::field("created_at").gte(Now::new()));
496// ```
497#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
498pub use reinhardt_db::orm::{
499	// Math functions
500	Abs,
501	// Utility functions
502	Cast,
503	Ceil,
504	// String functions
505	Concat,
506	// Date/time functions
507	CurrentDate,
508	CurrentTime,
509	Extract,
510	ExtractComponent,
511	Floor,
512	Greatest,
513	Least,
514	Length,
515	Lower,
516	Mod,
517	Now,
518	NullIf,
519	Power,
520	Round,
521	SqlType,
522	Sqrt,
523	Substr,
524	Trim,
525	TrimType,
526	Upper,
527};
528
529// Re-export ORM window functions
530//
531// # Availability
532//
533// Requires `database` feature.
534//
535// # Examples
536//
537// ```rust,no_run
538// # use reinhardt::{Window, RowNumber, Rank};
539// # struct Product;
540// # impl Product { fn objects() -> QueryBuilder { QueryBuilder } }
541// # struct Sale;
542// # impl Sale { fn objects() -> QueryBuilder { QueryBuilder } }
543// # struct QueryBuilder;
544// # impl QueryBuilder {
545// #     fn annotate(self, _name: &str, _val: impl std::any::Any) -> Self { self }
546// # }
547// // Add row numbers to query results
548// let query = Product::objects()
549//     .annotate("row_num", RowNumber::new()
550//         .over(Window::new().order_by("price")));
551//
552// // Ranking within partitions
553// let query = Sale::objects()
554//     .annotate("rank", Rank::new()
555//         .over(Window::new()
556//             .partition_by("category")
557//             .order_by("-amount")));
558// ```
559#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
560pub use reinhardt_db::orm::{
561	// Ranking functions
562	DenseRank,
563	// Value functions
564	FirstValue,
565	// Window specification
566	Frame,
567	FrameBoundary,
568	FrameType,
569	Lag,
570	LastValue,
571	Lead,
572	NTile,
573	NthValue,
574	Rank,
575	RowNumber,
576	Window,
577	WindowFunction,
578};
579
580// Re-export ORM constraints and indexes
581//
582// # Availability
583//
584// Requires `database` feature.
585//
586// # Examples
587//
588// ```rust,no_run
589// # use reinhardt::{UniqueConstraint, BTreeIndex};
590// // Define constraints programmatically
591// let constraint = UniqueConstraint::new(vec!["email"]);
592//
593// // Create indexes
594// let index = BTreeIndex::new("user_email_idx", vec!["email"]);
595// ```
596#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
597pub use reinhardt_db::orm::{
598	// Indexes
599	BTreeIndex,
600	// Constraints
601	CheckConstraint,
602	Constraint,
603	ForeignKeyConstraint,
604	GinIndex,
605	GistIndex,
606	HashIndex,
607	Index,
608	OnDelete,
609	OnUpdate,
610	UniqueConstraint,
611};
612
613// Re-export reinhardt-query prelude types (via reinhardt-db orm)
614// Query builder Query type is available as reinhardt::db::orm::Query
615// to avoid name conflict with reinhardt::Query (DI params extractor).
616// Value is re-exported as QueryBuilderValue to avoid conflicts with existing types.
617#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
618pub use reinhardt_db::orm::{IntoValue, Order, QueryBuilderValue};
619
620// Re-export database pool
621#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
622pub use reinhardt_db::pool::{ConnectionPool, PoolConfig, PoolError};
623
624// Re-export serializers
625#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
626pub use reinhardt_rest::serializers::{Deserializer, JsonSerializer, Serializer};
627
628// Re-export viewsets
629#[cfg(not(target_arch = "wasm32"))]
630pub use reinhardt_views::viewsets::{
631	Action, ActionType, CreateMixin, DestroyMixin, GenericViewSet, ListMixin, ModelViewSet,
632	ReadOnlyModelViewSet, RetrieveMixin, UpdateMixin, ViewSet,
633};
634
635// Re-export routers
636#[cfg(not(target_arch = "wasm32"))]
637pub use reinhardt_urls::routers::{
638	DefaultRouter, PathMatcher, PathPattern, Route, Router, ServerRouter, UrlPatternsRegistration,
639	clear_router, get_router, is_router_registered, register_router, register_router_arc,
640};
641
642// Re-export client-router types (requires client-router feature)
643// These types enable UnifiedRouter<V> with both .server() and .client() methods
644#[cfg(feature = "client-router")]
645pub use reinhardt_urls::routers::{
646	ClientPathPattern, ClientRoute, ClientRouteMatch, ClientRouter, FromPath, HistoryState,
647	NavigationType, ParamContext, SingleFromPath, UnifiedRouter,
648};
649// Path extractor for client-side routing (separate from server-side Path from reinhardt-di)
650#[cfg(feature = "client-router")]
651pub use reinhardt_urls::routers::Path as ClientPath;
652
653// Re-export auth
654#[cfg(all(feature = "auth", not(target_arch = "wasm32")))]
655#[allow(deprecated)] // CurrentUser is deprecated in favor of AuthUser
656pub use reinhardt_auth::{
657	AllowAny, AnonymousUser, AuthBackend, AuthInfo, AuthUser, BaseUser, CurrentUser, FullUser,
658	IsAdminUser, IsAuthenticated, PasswordHasher, Permission, PermissionsMixin, SimpleUser, User,
659	validate_auth_extractors,
660};
661
662// Re-export argon2-hasher gated types (DefaultUser, DefaultUserManager, Argon2Hasher)
663// These require the argon2-hasher feature because the entire default_user module
664// in reinhardt-auth is conditionally compiled with #[cfg(feature = "argon2-hasher")]
665#[cfg(all(
666	feature = "auth",
667	feature = "argon2-hasher",
668	not(target_arch = "wasm32")
669))]
670#[cfg_attr(docsrs, doc(cfg(all(feature = "auth", feature = "argon2-hasher"))))]
671pub use reinhardt_auth::{Argon2Hasher, DefaultUser, DefaultUserManager};
672
673#[cfg(all(feature = "auth-jwt", not(target_arch = "wasm32")))]
674pub use reinhardt_auth::{Claims, JwtAuth, JwtError};
675
676// Re-export auth management
677//
678// # Availability
679//
680// Requires `auth` feature.
681//
682// # Examples
683//
684// ```rust,no_run
685// # use reinhardt::{UserManager, GroupManager, ObjectPermission, CreateUserData, CreateGroupData};
686// # #[tokio::main]
687// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
688// // User management
689// let user_manager = UserManager::new();
690// // let user = user_manager.create_user(CreateUserData {
691// //     username: "alice".to_string(),
692// //     email: "alice@example.com".to_string(),
693// //     password: "secret".to_string(),
694// // }).await?;
695//
696// // Group management
697// let group_manager = GroupManager::new();
698// // let group = group_manager.create_group(CreateGroupData {
699// //     name: "editors".to_string(),
700// // }).await?;
701//
702// // Object-level permissions
703// // let perm = ObjectPermission::new("edit", user, article);
704// # Ok(())
705// # }
706// ```
707#[cfg(all(feature = "auth", not(target_arch = "wasm32")))]
708pub use reinhardt_auth::{
709	// Group management
710	CreateGroupData,
711	// User management
712	CreateUserData,
713	Group,
714	GroupManagementError,
715	GroupManagementResult,
716	GroupManager,
717	// Object-level permissions
718	ObjectPermission,
719	ObjectPermissionChecker,
720	ObjectPermissionManager,
721	UpdateUserData,
722	UserManagementError,
723	UserManagementResult,
724	UserManager,
725};
726
727// Re-export middleware
728// AuthenticationMiddleware requires both sessions (for session backend) and
729// middleware (for the reinhardt-middleware crate dependency)
730#[cfg(all(
731	feature = "sessions",
732	feature = "middleware",
733	not(target_arch = "wasm32")
734))]
735pub use reinhardt_middleware::AuthenticationMiddleware;
736
737#[cfg(all(
738	any(feature = "standard", feature = "middleware"),
739	not(target_arch = "wasm32")
740))]
741pub use reinhardt_middleware::LoggingMiddleware;
742
743#[cfg(all(feature = "middleware-cors", not(target_arch = "wasm32")))]
744pub use reinhardt_middleware::CorsMiddleware;
745
746// Re-export HTTP types (additional commonly used types)
747#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
748pub use reinhardt_http::Extensions;
749
750// Re-export HTTP types from hyper (already used in reinhardt_http)
751#[cfg(not(target_arch = "wasm32"))]
752pub use hyper::{Method, StatusCode};
753
754// Re-export pagination
755#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
756pub use reinhardt_rest::pagination::{
757	CursorPagination, LimitOffsetPagination, PageNumberPagination, PaginatedResponse, Paginator,
758};
759
760// Re-export filters
761#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
762pub use reinhardt_rest::filters::{
763	FieldOrderingExt, FilterBackend, FilterError, FilterResult, MultiTermSearch,
764};
765
766// Re-export throttling
767#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
768pub use reinhardt_rest::throttling::{
769	AnonRateThrottle, ScopedRateThrottle, Throttle, UserRateThrottle,
770};
771
772// Re-export signals
773#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
774pub use reinhardt_core::signals::{
775	M2MAction, M2MChangeEvent, Signal, m2m_changed, post_delete, post_save, pre_delete, pre_save,
776};
777
778// Re-export core utilities
779// Note: reinhardt_types provides Handler, Middleware, etc. which are already re-exported via reinhardt_apps
780
781// Re-export validators
782#[cfg(all(feature = "core", not(target_arch = "wasm32")))]
783pub use reinhardt_core::validators::{
784	CreditCardValidator, EmailValidator, IBANValidator, IPAddressValidator, PhoneNumberValidator,
785	UrlValidator, Validate, ValidationError as ValidatorError, ValidationErrors, ValidationResult,
786	Validator,
787};
788
789// Re-export views
790#[cfg(not(target_arch = "wasm32"))]
791pub use reinhardt_views::{
792	Context, DetailView, ListView, MultipleObjectMixin, SingleObjectMixin, View,
793};
794
795// Re-export parsers
796#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
797pub use reinhardt_rest::parsers::{
798	FileUploadParser, FormParser, JSONParser, MediaType, MultiPartParser, ParseError, ParseResult,
799	Parser,
800};
801
802// Re-export versioning
803#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
804pub use reinhardt_rest::versioning::{
805	AcceptHeaderVersioning, BaseVersioning, HostNameVersioning, NamespaceVersioning,
806	QueryParameterVersioning, RequestVersionExt, URLPathVersioning, VersioningError,
807	VersioningMiddleware,
808};
809
810// Re-export metadata
811#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
812pub use reinhardt_rest::metadata::{
813	ActionMetadata, BaseMetadata, ChoiceInfo, FieldInfo, FieldInfoBuilder, FieldType,
814	MetadataOptions, MetadataResponse, SimpleMetadata,
815};
816
817// Re-export negotiation
818#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
819pub use reinhardt_rest::negotiation::*;
820
821// Re-export REST integration modules
822#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
823pub use reinhardt_rest::{
824	filters, metadata, negotiation, pagination, parsers, serializers, throttling, versioning,
825};
826
827// Re-export browsable API (from reinhardt-browsable-api via reinhardt-rest)
828#[cfg(all(feature = "rest", not(target_arch = "wasm32")))]
829pub use reinhardt_rest::browsable_api;
830
831// Re-export OpenAPI types
832//
833// # Availability
834//
835// Requires `openapi` feature.
836//
837// # Examples
838//
839// ```rust,no_run
840// # // Note: This example requires the openapi feature
841// // use reinhardt::{OpenApi, ApiDoc};
842// //
843// // // Define API documentation
844// // #[derive(OpenApi)]
845// // #[openapi(paths(get_users, create_user))]
846// // struct ApiDoc;
847// //
848// // // Generate OpenAPI schema
849// // let openapi = ApiDoc::openapi();
850// // let json = serde_json::to_string_pretty(&openapi)?;
851// ```
852#[cfg(all(feature = "openapi", not(target_arch = "wasm32")))]
853pub use reinhardt_rest::openapi::*;
854
855// Re-export OpenApiRouter (requires openapi-router feature)
856#[cfg(all(feature = "openapi-router", not(target_arch = "wasm32")))]
857pub use reinhardt_openapi::OpenApiRouter;
858
859// Re-export shortcuts (Django-style convenience functions)
860#[cfg(all(feature = "shortcuts", not(target_arch = "wasm32")))]
861pub use reinhardt_shortcuts::{redirect, render_html, render_json, render_text};
862// ORM-integrated shortcuts require database feature
863#[cfg(all(
864	feature = "shortcuts",
865	feature = "database",
866	not(target_arch = "wasm32")
867))]
868pub use reinhardt_shortcuts::{get_list_or_404, get_object_or_404};
869
870// Re-export URL utilities
871#[cfg(not(target_arch = "wasm32"))]
872pub use reinhardt_urls::routers::{
873	UrlPattern, UrlPatternWithParams, UrlReverser, include_routes as include, path, re_path,
874	reverse,
875};
876
877// Admin functionality is available through reinhardt-admin-api crate
878// See reinhardt-admin-types for type definitions
879
880// Re-export database related (database feature)
881#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
882pub use reinhardt_db::contenttypes::{
883	CONTENT_TYPE_REGISTRY, ContentType, ContentTypeRegistry, GenericForeignKey, GenericRelatable,
884	GenericRelationQuery, ModelType,
885};
886#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
887pub use reinhardt_db::migrations::{
888	FieldState, Migration, MigrationAutodetector, MigrationError, MigrationPlan, MigrationRecorder,
889	ModelState, ProjectState,
890};
891
892// Re-export cache (cache feature)
893#[cfg(all(feature = "cache", not(target_arch = "wasm32")))]
894pub use reinhardt_utils::cache::{Cache, CacheKeyBuilder, InMemoryCache};
895
896// Cache middleware is in reinhardt-middleware
897#[cfg(all(feature = "middleware", not(target_arch = "wasm32")))]
898pub use reinhardt_middleware::CacheMiddleware;
899
900#[cfg(all(
901	feature = "cache",
902	feature = "redis-backend",
903	not(target_arch = "wasm32")
904))]
905pub use reinhardt_utils::cache::RedisCache;
906
907// Re-export sessions (sessions feature)
908#[cfg(all(feature = "sessions", not(target_arch = "wasm32")))]
909pub use reinhardt_auth::sessions::{
910	CacheSessionBackend, InMemorySessionBackend, Session, SessionBackend, SessionError,
911};
912
913#[cfg(all(
914	feature = "sessions",
915	feature = "middleware",
916	not(target_arch = "wasm32")
917))]
918pub use reinhardt_auth::sessions::{HttpSessionConfig, SameSite, SessionMiddleware};
919
920// Re-export contrib modules (contrib feature)
921// Note: reinhardt_contrib exports individual modules (auth, sessions, etc.)
922// rather than a single "contrib" module
923
924// Re-export forms (forms feature)
925#[cfg(all(feature = "forms", not(target_arch = "wasm32")))]
926pub use reinhardt_forms::{
927	BoundField, CharField, EmailField, FieldError, FileField, Form, FormError, FormResult,
928	IntegerField, ModelForm,
929};
930
931// Re-export DI and parameters (FastAPI-style parameter extraction)
932#[cfg(all(feature = "di", not(target_arch = "wasm32")))]
933pub use reinhardt_di::injected::{Injected, OptionalInjected};
934#[cfg(all(feature = "di", not(target_arch = "wasm32")))]
935pub use reinhardt_di::scope::{RequestScope, Scope, SingletonScope};
936#[cfg(all(feature = "di", not(target_arch = "wasm32")))]
937pub use reinhardt_di::{
938	Depends, DependsBuilder, DiError, DiResult, Injectable, InjectionContext,
939	InjectionContextBuilder, InjectionMetadata, RequestContext,
940};
941
942// Re-export DI params - available in minimal, standard, and di features
943#[cfg(all(
944	any(feature = "minimal", feature = "standard", feature = "di"),
945	not(target_arch = "wasm32")
946))]
947pub use reinhardt_di::params::{Body, Cookie, Header, Json, Path, Query};
948
949// Re-export template/rendering functionality from reinhardt-pages
950// Note: TemplateError was removed as Tera templating was replaced with reinhardt-pages SSR
951
952// Re-export tasks
953#[cfg(all(feature = "tasks", not(target_arch = "wasm32")))]
954pub use reinhardt_tasks::{Scheduler, Task, TaskExecutor, TaskQueue};
955
956// Re-export test utilities
957#[cfg(all(feature = "test", not(target_arch = "wasm32")))]
958pub use reinhardt_test::{APIClient, APIRequestFactory, APITestCase, TestResponse};
959
960// Re-export storage
961#[cfg(all(feature = "storage", not(target_arch = "wasm32")))]
962pub use reinhardt_utils::storage::{InMemoryStorage, LocalStorage, Storage};
963
964/// Convenience re-exports of commonly used types (server-side only).
965#[cfg(not(target_arch = "wasm32"))]
966pub mod prelude {
967	// Core types - always available
968	pub use crate::{
969		Action,
970		DefaultRouter,
971		DetailView,
972		ListView,
973		ModelViewSet,
974		MultipleObjectMixin,
975		ReadOnlyModelViewSet,
976		Route,
977		Router,
978		ServerRouter,
979		SingleObjectMixin,
980		StatusCode,
981		View,
982		ViewSet,
983		// Routers
984		clear_router,
985		get_router,
986		is_router_registered,
987		register_router,
988	};
989
990	// ViewResult requires core feature (re-exported from reinhardt_http)
991	#[cfg(feature = "core")]
992	pub use crate::ViewResult;
993
994	// UnifiedRouter requires client-router feature
995	#[cfg(feature = "client-router")]
996	pub use crate::UnifiedRouter;
997
998	// External dependencies (via core)
999	#[cfg(feature = "core")]
1000	pub use crate::core::async_trait;
1001	#[cfg(feature = "core")]
1002	pub use crate::core::serde::{Deserialize, Serialize};
1003
1004	// Core feature - types, signals, etc.
1005	#[cfg(feature = "core")]
1006	pub use crate::{
1007		Error, Handler, Middleware, MiddlewareChain, Request, Response, Result, Signal,
1008		m2m_changed, post_delete, post_save, pre_delete, pre_save,
1009	};
1010
1011	// HTTP method macros - always available
1012	pub use crate::{api_view, delete, get, patch, post, put};
1013
1014	// Database feature - ORM and Model macros
1015	#[cfg(feature = "database")]
1016	pub use crate::{
1017		Aggregate,
1018		// Annotations and aggregations
1019		Annotation,
1020		CheckConstraint,
1021		// Common database functions
1022		Concat,
1023		CurrentDate,
1024		DatabaseConnection,
1025		DenseRank,
1026		// Query expressions (Django-style F/Q objects)
1027		F,
1028		ForeignKeyConstraint,
1029		Lower,
1030		Now,
1031		Q,
1032		QOperator,
1033		Rank,
1034		RowNumber,
1035		SoftDeletable,
1036		Timestamped,
1037		// Transaction management
1038		Transaction,
1039		// Constraints
1040		UniqueConstraint,
1041		Upper,
1042		// Window functions (commonly used)
1043		Window,
1044		atomic,
1045		// Model attribute macro for struct-level model definition
1046		model,
1047	};
1048
1049	// Import Model trait directly from reinhardt_db to avoid name shadowing
1050	// (crate::Model refers to the derive macro, not the trait)
1051	#[cfg(feature = "database")]
1052	pub use reinhardt_db::orm::Model;
1053
1054	// Auth feature
1055	#[cfg(feature = "auth")]
1056	pub use crate::{
1057		AuthBackend,
1058		Group,
1059		GroupManager,
1060		// Object-level permissions
1061		ObjectPermission,
1062		ObjectPermissionChecker,
1063		PasswordHasher,
1064		Permission,
1065		SimpleUser,
1066		User,
1067		// User and group management
1068		UserManager,
1069	};
1070
1071	// OpenAPI feature - schema generation and documentation
1072	// Note: When 'openapi' feature is enabled, types are available at top level
1073	// Example: use reinhardt::prelude::*; or use reinhardt::{OpenApi, ApiDoc, Schema};
1074
1075	// DI params - FastAPI-style parameter extraction
1076	#[cfg(any(feature = "minimal", feature = "standard", feature = "di"))]
1077	pub use crate::{Body, Cookie, Header, Json, Path, Query};
1078
1079	// REST feature - serializers, parsers, pagination, throttling, versioning, metadata
1080	#[cfg(feature = "rest")]
1081	pub use crate::{
1082		// Versioning
1083		AcceptHeaderVersioning,
1084		// Throttling
1085		AnonRateThrottle,
1086		CursorPagination,
1087		FormParser,
1088		// Parsers
1089		JSONParser,
1090		JsonSerializer,
1091		LimitOffsetPagination,
1092		MultiPartParser,
1093		// Filters
1094		MultiTermSearch,
1095		// Pagination
1096		PageNumberPagination,
1097		Paginator,
1098		Parser,
1099		QueryParameterVersioning,
1100		ScopedRateThrottle,
1101		// Serializers
1102		Serializer,
1103		// Metadata
1104		SimpleMetadata,
1105		Throttle,
1106		URLPathVersioning,
1107		UserRateThrottle,
1108		VersioningMiddleware,
1109	};
1110
1111	// Settings feature
1112	#[cfg(feature = "conf")]
1113	#[allow(deprecated)] // Re-exports deprecated Settings for backward compatibility
1114	pub use crate::Settings;
1115
1116	// Middleware
1117	#[cfg(any(feature = "standard", feature = "middleware"))]
1118	pub use crate::LoggingMiddleware;
1119
1120	// Sessions feature
1121	#[cfg(all(
1122		feature = "sessions",
1123		feature = "middleware",
1124		not(target_arch = "wasm32")
1125	))]
1126	pub use crate::AuthenticationMiddleware;
1127	#[cfg(feature = "sessions")]
1128	pub use crate::Session;
1129
1130	// Cache feature
1131	#[cfg(feature = "cache")]
1132	pub use crate::{Cache, InMemoryCache};
1133
1134	// Admin feature - use reinhardt-admin-api crate directly for admin functionality
1135}
1136
1137// Re-export WebSocket types
1138#[cfg(all(feature = "websockets-pages", not(target_arch = "wasm32")))]
1139pub use reinhardt_websockets::integration::pages::PagesAuthenticator;
1140#[cfg(all(feature = "websockets", not(target_arch = "wasm32")))]
1141pub use reinhardt_websockets::room::RoomManager;
1142#[cfg(all(feature = "websockets", not(target_arch = "wasm32")))]
1143pub use reinhardt_websockets::{
1144	ConsumerContext, Message, WebSocketConsumer, WebSocketError, WebSocketResult,
1145};
1146#[cfg(all(feature = "websockets", not(target_arch = "wasm32")))]
1147pub use reinhardt_websockets::{
1148	RouteError, RouteResult, WebSocketRoute, WebSocketRouter, clear_websocket_router,
1149	get_websocket_router, register_websocket_router, reverse_websocket_url,
1150};
1151
1152/// SQL query builder module.
1153///
1154/// Re-exports [`reinhardt_query`] for building type-safe SQL queries.
1155/// Requires `database` feature.
1156#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
1157pub mod query;
1158
1159/// Database re-exports for Model derive macro generated code.
1160///
1161/// These must be available at `::reinhardt::db::*` for the macro to work correctly.
1162#[cfg(all(feature = "database", not(target_arch = "wasm32")))]
1163pub mod db {
1164	// Re-export commonly used types at module level for easier access
1165	pub use reinhardt_db::DatabaseConnection;
1166	pub use reinhardt_db::DatabaseError as Error;
1167
1168	/// Database migration types and utilities.
1169	pub mod migrations {
1170		pub use reinhardt_db::migrations::*;
1171	}
1172
1173	/// ORM query building and model operations.
1174	pub mod orm {
1175		pub use reinhardt_db::orm::*;
1176	}
1177
1178	/// Model relationship (association) definitions.
1179	pub mod associations {
1180		pub use reinhardt_db::associations::*;
1181	}
1182
1183	/// Convenience re-exports for database operations.
1184	pub mod prelude {
1185		pub use reinhardt_db::prelude::*;
1186	}
1187}