1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
//! # Toxi Web Framework
//!
//! **Toxi** is a modular, batteries-included web framework for Rust.
//! Built on `hyper` and `tokio`, it provides a complete stack for building
//! production HTTP services — routing, ORM, authentication, real-time
//! communication, background jobs, caching, storage, templates, email,
//! and OpenAPI generation.
//!
//! ## Quick Start
//!
//! ```toml
//! [dependencies]
//! toxi = { version = "3.1.0", features = ["full"] }
//! tokio = { version = "1", features = ["full"] }
//! serde = { version = "1", features = ["derive"] }
//! ```
//!
//! ```rust,no_run
//! use toxi::prelude::*;
//!
//! async fn hello(_req: Request) -> Result<Response> {
//! Ok(Response::text("Hello, Toxi!"))
//! }
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//! let mut app = Application::new(Config::load().unwrap());
//! app.router_mut().get("/", hello);
//! app.run().await
//! }
//! ```
//!
//! ## Feature Flags
//!
//! Enable only what you need via Cargo features:
//!
//! | Feature | Crate | Description |
//! |-------------|---------------------|---------------------------------------|
//! | `database` | `toxi-db` | ORM with relationships & migrations |
//! | `auth` | `toxi-auth` | JWT, OAuth2, RBAC, 2FA, API keys |
//! | `queue` | `toxi-queue` | Background job orchestration |
//! | `cache` | `toxi-cache` | In-memory and Redis caching |
//! | `realtime` | `toxi-realtime` | WebSocket and SSE |
//! | `templates` | `toxi-template` | Server-side rendering |
//! | `mail` | `toxi-mail` | SMTP email delivery |
//! | `storage` | `toxi-storage` | Local and S3 file storage |
//! | `security` | `toxi-security` | Crypto primitives |
//! | `utils` | `toxi-utils` | String, date, validation helpers |
//! | `graphql` | `toxi-graphql` | GraphQL integration |
//! | `plugin` | `toxi-plugin` | Plugin lifecycle hooks |
//! | `full` | all of the above | Every optional crate |
//!
//! ## Modular by Design
//!
//! Each crate in the Toxi ecosystem can be used independently:
//!
//! ```toml
//! # Minimal: just routing and HTTP
//! [dependencies]
//! toxi-core = "3.1.0"
//!
//! # Add database when needed
//! [dependencies]
//! toxi-core = "3.1.0"
//! toxi-db = "3.1.0"
//! ```
//!
//! ## Key Concepts
//!
//! - **Extractors** — Typed data pulled from requests (`Json<T>`, `Path<T>`, `State<T>`, etc.)
//! - **Handlers** — Async functions whose parameters are extractors
//! - **Middleware** — Tower-compatible layers (CORS, logging, compression, rate limiting)
//! - **HTTP/2** — First-class support via ALPN or `Server::with_http_version`
//!
//! ## Learn More
//!
//! - [GitHub](https://github.com/meshackbahati/toxi)
//! - [API Documentation](https://docs.rs/toxi)
// ── Core re-exports ──────────────────────────────────────────────────
/// Re-export all items from [`toxi_core`].
pub use *;
/// Re-export the `extract` module from [`toxi_core`].
pub use extract;
/// Re-export [`toxi_middleware`] as `middleware`.
pub use toxi_middleware as middleware;
/// Re-export [`toxi_config`] as `config`.
pub use toxi_config as config;
/// Re-export [`ToxiRequest`] and [`ToxiResponse`].
pub use ;
// ── Macro re-exports ─────────────────────────────────────────────────
/// Re-export `impl_handler_for_fn!` — extend handler arity beyond the
/// built-in 12 extractors:
///
/// ```rust,ignore
/// // Enable 13 and 14 extractor handlers
/// toxi::impl_handler_for_fn!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14);
/// ```
pub use impl_handler_for_fn;
/// Re-export `json_response!` — create a JSON response from inline JSON:
///
/// ```rust,ignore
/// use toxi::prelude::*;
///
/// async fn health() -> Result<Response> {
/// Ok(json_response!({ "status": "ok" }))
/// }
/// ```
pub use json_response;
// ── Optional crate re-exports (behind feature flags) ─────────────────
/// Re-export [`toxi_db`] as `db` — ORM with relationships, migrations,
/// soft deletes, and eager loading.
pub use toxi_db as db;
/// Re-export [`toxi_auth`] as `auth` — JWT, OAuth2, RBAC, 2FA, and API keys.
pub use toxi_auth as auth;
/// Re-export [`toxi_queue`] as `queue` — background job orchestration
/// with Postgres and Redis backends.
pub use toxi_queue as queue;
/// Re-export [`toxi_cache`] as `cache` — in-memory and Redis caching.
pub use toxi_cache as cache;
/// Re-export [`toxi_realtime`] as `realtime` — WebSocket, SSE, and
/// event broadcasting.
pub use toxi_realtime as realtime;
/// Re-export [`toxi_template`] as `template` — server-side rendering.
pub use toxi_template as template;
/// Re-export [`toxi_mail`] as `mail` — SMTP email delivery.
pub use toxi_mail as mail;
/// Re-export [`toxi_storage`] as `storage` — local and S3 file storage.
pub use toxi_storage as storage;
/// Re-export [`toxi_security`] as `security` — cryptographic primitives.
pub use toxi_security as security;
/// Re-export [`toxi_utils`] as `utils` — string, date, and validation helpers.
pub use toxi_utils as utils;
// ── Prelude ──────────────────────────────────────────────────────────
/// Convenience re-exports for ergonomic imports.
///
/// ```rust,ignore
/// use toxi::prelude::*;
/// ```
/// Configuration helper utilities.
/// Re-export of [`cors_layer_from_config`].
pub use cors_layer_from_config;