-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCargo.toml
More file actions
296 lines (253 loc) · 9.03 KB
/
Cargo.toml
File metadata and controls
296 lines (253 loc) · 9.03 KB
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# SPDX-FileCopyrightText: 2025-2026 RAprogramm <andrey.rozanov.vl@gmail.com>
#
# SPDX-License-Identifier: MIT
[package]
name = "masterror"
version = "0.27.3"
rust-version = "1.93"
edition = "2024"
license = "MIT"
repository = "https://github.com/RAprogramm/masterror"
readme = "README.md"
description = "Application error types and response mapping"
documentation = "https://docs.rs/masterror"
build = "build.rs"
categories = ["rust-patterns", "web-programming", "no-std"]
keywords = ["error", "api", "framework", "error-handling"]
include = [
"Cargo.toml",
"Cargo.lock",
"build.rs",
"src/**",
"tests/**",
"README.md",
"README.ru.md",
"README.ko.md",
"README.template.md",
"CHANGELOG.md",
"LICENSE",
"Makefile.toml",
"deny.toml",
"idea.md",
"target.md",
"build/**",
"masterror-derive/**",
"masterror-template/**",
".cargo/audit.toml",
".cargo/config.toml",
]
[workspace]
members = [
"masterror-derive",
"masterror-template",
"examples/axum-rest-api",
"examples/custom-domain-errors",
"examples/sqlx-database",
"examples/basic-async",
]
resolver = "3"
# Defaults for members (root объявлен строками выше, потому что build.rs парсит его как строки)
[workspace.package]
edition = "2024"
rust-version = "1.93"
license = "MIT"
repository = "https://github.com/RAprogramm/masterror"
readme = "README.md"
[features]
default = ["std"]
std = ["uuid/std", "serde/std"]
tracing = ["dep:tracing", "dep:log", "dep:log-mdc", "std"]
metrics = ["dep:metrics", "std"]
backtrace = ["std"]
colored = ["dep:owo-colors", "std"]
axum = ["dep:axum", "dep:serde_json", "std"]
actix = ["dep:actix-web", "dep:serde_json", "std"]
# Разделили: лёгкая обработка ошибок (sqlx-core) и опциональные миграции (полный sqlx)
sqlx = ["dep:sqlx-core"] # maps sqlx_core::Error
sqlx-migrate = ["dep:sqlx"] # maps sqlx::migrate::MigrateError
redis = ["dep:redis", "std"]
validator = ["dep:validator", "std"]
serde_json = ["dep:serde_json", "std"]
config = ["dep:config", "std"]
multipart = ["axum", "std"]
tokio = ["dep:tokio", "std"]
reqwest = ["dep:reqwest", "std"]
teloxide = ["dep:teloxide-core", "std"]
init-data = ["dep:init-data-rs", "std"]
frontend = ["dep:wasm-bindgen", "dep:js-sys", "dep:serde-wasm-bindgen", "std"]
turnkey = ["std"]
tonic = ["dep:tonic", "std"]
openapi = ["dep:utoipa", "std"]
benchmarks = ["std"]
[workspace.dependencies]
masterror-derive = { version = "0.11" }
masterror-template = { version = "0.4" }
[dependencies]
masterror-derive = { version = "0.11" }
masterror-template = { workspace = true }
tracing = { version = "0.1", optional = true, default-features = false, features = [
"attributes",
"std",
] }
log = { version = "0.4", optional = true }
log-mdc = { version = "0.1", optional = true }
metrics = { version = "0.24", optional = true }
serde = { version = "1", default-features = false, features = [
"derive",
"alloc",
] }
serde_json = { version = "1", optional = true, default-features = false, features = [
"std",
] }
http = "1"
sha2 = "0.10"
itoa = "1"
ryu = "1"
# optional integrations
axum = { version = "0.8", optional = true, default-features = false, features = [
"json",
"multipart",
] }
actix-web = { version = "4", optional = true, default-features = false, features = [
"macros",
] }
# Lean core only; no drivers, no TLS, no macros
sqlx-core = { version = "0.8", optional = true, default-features = false }
# Full sqlx ONLY for migrate mapping; still no default features
sqlx = { version = "0.8", optional = true, default-features = false, features = [
"migrate",
] }
redis = { version = "1", optional = true, default-features = false }
validator = { version = "0.20", optional = true, features = ["derive"] }
config = { version = "0.15", optional = true }
utoipa = { version = "5.4", optional = true }
tokio = { version = "1", optional = true, features = ["time"] }
reqwest = { version = "0.13", optional = true, default-features = false }
teloxide-core = { version = "0.13", optional = true, default-features = false }
init-data-rs = { version = "0.1", optional = true }
wasm-bindgen = { version = "0.2", optional = true }
js-sys = { version = "0.3", optional = true }
serde-wasm-bindgen = { version = "0.6", optional = true }
uuid = { version = "1", default-features = false }
tonic = { version = "0.14", optional = true }
owo-colors = { version = "4", optional = true, default-features = false, features = [
"supports-colors",
] }
[dev-dependencies]
anyhow = { version = "1", default-features = false, features = ["std"] }
criterion = "0.8"
serde_json = "1"
thiserror = "2.0"
tokio = { version = "1", features = [
"macros",
"rt-multi-thread",
"net",
"time",
], default-features = false }
trybuild = "1"
toml = "1"
tempfile = "3"
tracing-subscriber = { version = "0.3", features = ["registry"] }
# reqwest 0.12 для совместимости с teloxide-core в тестах
reqwest-012 = { package = "reqwest", version = "0.12", default-features = false, features = [
"rustls-tls",
] }
[[bench]]
name = "error_paths"
harness = false
[[bench]]
name = "comparison"
harness = false
[build-dependencies]
serde = { version = "1", features = ["derive"] }
toml = "1"
[package.metadata.masterror.readme]
feature_order = [
"std",
"axum",
"actix",
"openapi",
"serde_json",
"tracing",
"metrics",
"backtrace",
"colored",
"sqlx",
"sqlx-migrate",
"reqwest",
"redis",
"validator",
"config",
"tokio",
"multipart",
"teloxide",
"init-data",
"tonic",
"frontend",
"turnkey",
"benchmarks",
]
feature_snippet_group = 4
conversion_lines = [
"`std::io::Error` → Internal",
"`String` → BadRequest",
"`sqlx::Error` → NotFound/Database",
"`redis::RedisError` → Cache",
"`reqwest::Error` → Timeout/Network/ExternalApi",
"`axum::extract::multipart::MultipartError` → BadRequest",
"`validator::ValidationErrors` → Validation",
"`config::ConfigError` → Config",
"`tokio::time::error::Elapsed` → Timeout",
"`teloxide_core::RequestError` → RateLimited/Network/ExternalApi/Deserialization/Internal",
"`init_data_rs::InitDataError` → TelegramAuth",
]
[package.metadata.masterror.readme.features.axum]
description = "IntoResponse integration with structured JSON bodies"
[package.metadata.masterror.readme.features.actix]
description = "Actix Web ResponseError and Responder implementations"
[package.metadata.masterror.readme.features.std]
description = "Enable std support (default); required for runtime integrations"
[package.metadata.masterror.readme.features.openapi]
description = "Generate utoipa OpenAPI schema for ErrorResponse"
[package.metadata.masterror.readme.features.serde_json]
description = "Attach structured JSON details to AppError"
[package.metadata.masterror.readme.features.tracing]
description = "Emit structured tracing events when errors are constructed"
[package.metadata.masterror.readme.features.metrics]
description = "Increment `error_total{code,category}` counter for each AppError"
[package.metadata.masterror.readme.features.backtrace]
description = "Capture lazy `Backtrace` snapshots when telemetry is flushed"
[package.metadata.masterror.readme.features.colored]
description = "Optional colored terminal output with automatic TTY detection"
[package.metadata.masterror.readme.features.sqlx]
description = "Classify sqlx_core::Error variants into AppError kinds"
[package.metadata.masterror.readme.features.sqlx-migrate]
description = "Map sqlx::migrate::MigrateError into AppError (Database)"
[package.metadata.masterror.readme.features.reqwest]
description = "Classify reqwest::Error as timeout/network/external API"
[package.metadata.masterror.readme.features.redis]
description = "Map redis::RedisError into cache-aware AppError"
[package.metadata.masterror.readme.features.validator]
description = "Convert validator::ValidationErrors into validation failures"
[package.metadata.masterror.readme.features.config]
description = "Propagate config::ConfigError as configuration issues"
[package.metadata.masterror.readme.features.multipart]
description = "Handle axum multipart extraction errors"
[package.metadata.masterror.readme.features.tokio]
description = "Classify tokio::time::error::Elapsed as timeout"
[package.metadata.masterror.readme.features.teloxide]
description = "Convert teloxide_core::RequestError into domain errors"
[package.metadata.masterror.readme.features."init-data"]
description = "Convert init-data-rs validation errors for Telegram Mini Apps"
[package.metadata.masterror.readme.features.tonic]
description = "Convert AppError into tonic::Status with redaction"
[package.metadata.masterror.readme.features.frontend]
description = "Log to the browser console and convert to JsValue on WASM"
[package.metadata.masterror.readme.features.turnkey]
description = "Ship Turnkey-specific error taxonomy and conversions"
[package.metadata.masterror.readme.features.benchmarks]
description = "Enable Criterion benchmarks and CI baseline tooling"
extra = ["Primarily used for local profiling and continuous benchmarking runs"]
[lib]
crate-type = ["cdylib", "rlib"]
bench = false