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
//! Typed, composable HTTP error sets for Axum and Aide.
//!
//! `axum-error-sets` provides compile-time guarantees for HTTP error handling in Axum applications.
//! Instead of using monolithic error enums or loosely-typed responses, functions declare the exact set
//! of HTTP status codes they can return using type-level tuple sets (e.g., `(NotFound, Unauthorized)`).
//!
//! ### Key Concepts & Features
//!
//! * **Powered by [`type-sets`](https://docs.rs/type-sets/):** Uses type-level set operations under the hood to manage,
//! contain, and convert tuple sets of status codes at compile time.
//! * **No Per-Function Custom Error Enums:** Eliminates the need to construct large, domain-wide error enums or
//! define bespoke `Error` types for every function layer.
//! * **Exact Error Contracts:** Functions declare precisely which HTTP status codes they can produce in their return signature.
//! * **Subset-to-Superset Promotion:** Error sets grow deterministically as they move up application layers
//! via `.into_superset()`. Lower-level code remains precise without restricting higher-level callers.
//! * **Custom Response Formatting:** Implement [`ErrorSetValue`] on your central error payload type (e.g., `AppError` or `StringError`)
//! to completely control how Axum converts error values into [`IntoResponse`](axum::response::IntoResponse) for any given status code.
//! * **Compile-Time Guarantees:** Returning an undeclared status code produces a compiler error. Callers cannot silently "forget"
//! or shrink handled error sets without explicit conversion.
//! * **Aide & OpenAPI Integration:** Implement [`AideErrorSetValue`] to automatically generate precise OpenAPI metadata for every status code in an error set.
//!
//! ---
//!
//! For complete runnable code, visit the [`examples/`](https://github.com/your-org/axum-error-sets/tree/main/examples) directory on GitHub.
//!
//! ### Example 1: Basic Status Mapping
//!
//! Demonstrates converting `Result` types directly into typed HTTP error statuses using `StatusResultExt`.
//!
//! ```rust,ignore
//! ```
//!
//! ---
//!
//! ### Example 2: Error Set Composition
//!
//! Demonstrates how lower-level functions with small error sets transparently expand into larger caller-level contracts using `into_superset()`.
//!
//! ```rust,ignore
//! ```
//!
//! ---
//!
//! ### Example 3: Axum Route Handlers & Aide OpenAPI Integration
//!
//! Demonstrates integrating error sets directly into Axum handlers to automatically generate OpenAPI metadata.
//!
//! ```rust,ignore
//! ```
use Response;
use StatusCode;
use Contains;
/// Implemented for all types that can be used as `E` inside [`ApiError<_, E>`].
///
/// implemented for [`NotFound`](crate::code::NotFound),
/// [`InternalServerError`](crate::code::InternalServerError), etc.
/// Should be implemented for a type to be used as `T` inside [`ApiError<T, _>`].
/// Should be implemented for a type to be used as `T` inside [`ApiError<T, _>`], for
/// usage with [`aide`].
pub use *;
pub use *;