Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ All notable changes to this project will be documented in this file.
### Added
- _Nothing yet._

## [0.5.9] - 2025-10-01

### Added
- `TemplateFormatterKind` enumerating the formatter traits supported by
`#[error("...")]`, plus `TemplateFormatter::from_kind`/`kind()` helpers for
constructing and inspecting placeholders programmatically.

### Changed
- Formatter parsing now routes through `TemplateFormatterKind`, ensuring lookup
tables, `is_alternate` handling and downstream derives share the same
canonical representation.

### Documentation
- Documented `TemplateFormatterKind` usage and the new inspection helpers
across README variants.

## [0.5.8] - 2025-09-30

### Changed
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "masterror"
version = "0.5.8"
version = "0.5.9"
rust-version = "1.90"
edition = "2024"
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -50,7 +50,7 @@ openapi = ["dep:utoipa"]

[workspace.dependencies]
masterror-derive = { version = "0.1.4", path = "masterror-derive" }
masterror-template = { version = "0.1.2", path = "masterror-template" }
masterror-template = { version = "0.1.3", path = "masterror-template" }

[dependencies]
masterror-derive = { workspace = true }
Expand Down
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ Stable categories, conservative HTTP mapping, no `unsafe`.

~~~toml
[dependencies]
masterror = { version = "0.5.8", default-features = false }
masterror = { version = "0.5.9", default-features = false }
# or with features:
# masterror = { version = "0.5.8", features = [
# masterror = { version = "0.5.9", features = [
# "axum", "actix", "openapi", "serde_json",
# "sqlx", "sqlx-migrate", "reqwest", "redis",
# "validator", "config", "tokio", "multipart",
Expand Down Expand Up @@ -66,10 +66,10 @@ masterror = { version = "0.5.8", default-features = false }
~~~toml
[dependencies]
# lean core
masterror = { version = "0.5.8", default-features = false }
masterror = { version = "0.5.9", default-features = false }

# with Axum/Actix + JSON + integrations
# masterror = { version = "0.5.8", features = [
# masterror = { version = "0.5.9", features = [
# "axum", "actix", "openapi", "serde_json",
# "sqlx", "sqlx-migrate", "reqwest", "redis",
# "validator", "config", "tokio", "multipart",
Expand Down Expand Up @@ -155,6 +155,9 @@ assert_eq!(wrapped.to_string(), "I/O failed: disk offline");
- `TemplateFormatter` mirrors `thiserror`'s formatter detection so existing
derives that relied on hexadecimal, pointer or exponential renderers keep
compiling.
- `TemplateFormatterKind` exposes the formatter trait requested by a
placeholder, making it easy to branch on the requested rendering behaviour
without manually matching every enum variant.

#### Formatter traits

Expand Down Expand Up @@ -211,7 +214,9 @@ assert!(rendered.contains("upper=1.5625E-1"));
~~~

~~~rust
use masterror::error::template::{ErrorTemplate, TemplateFormatter};
use masterror::error::template::{
ErrorTemplate, TemplateFormatter, TemplateFormatterKind
};

let template = ErrorTemplate::parse("{code:#x} → {payload:?}").expect("parse");
let mut placeholders = template.placeholders();
Expand All @@ -221,6 +226,8 @@ assert!(matches!(
code.formatter(),
TemplateFormatter::LowerHex { alternate: true }
));
assert_eq!(code.formatter().kind(), TemplateFormatterKind::LowerHex);
assert!(code.formatter().is_alternate());

let payload = placeholders.next().expect("payload placeholder");
assert_eq!(
Expand Down Expand Up @@ -342,13 +349,13 @@ assert_eq!(resp.status, 401);
Minimal core:

~~~toml
masterror = { version = "0.5.8", default-features = false }
masterror = { version = "0.5.9", default-features = false }
~~~

API (Axum + JSON + deps):

~~~toml
masterror = { version = "0.5.8", features = [
masterror = { version = "0.5.9", features = [
"axum", "serde_json", "openapi",
"sqlx", "reqwest", "redis", "validator", "config", "tokio"
] }
Expand All @@ -357,7 +364,7 @@ masterror = { version = "0.5.8", features = [
API (Actix + JSON + deps):

~~~toml
masterror = { version = "0.5.8", features = [
masterror = { version = "0.5.9", features = [
"actix", "serde_json", "openapi",
"sqlx", "reqwest", "redis", "validator", "config", "tokio"
] }
Expand Down
9 changes: 7 additions & 2 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,13 @@ assert!(rendered.contains("upper=1.5625E-1"));
~~~

`masterror::error::template::ErrorTemplate` позволяет разобрать шаблон и
программно проверить запрошенные форматтеры:
программно проверить запрошенные форматтеры; перечисление
`TemplateFormatterKind` возвращает название трейта для каждого плейсхолдера:

~~~rust
use masterror::error::template::{ErrorTemplate, TemplateFormatter};
use masterror::error::template::{
ErrorTemplate, TemplateFormatter, TemplateFormatterKind
};

let template = ErrorTemplate::parse("{code:#x} → {payload:?}").expect("parse");
let mut placeholders = template.placeholders();
Expand All @@ -149,6 +152,8 @@ assert!(matches!(
code.formatter(),
TemplateFormatter::LowerHex { alternate: true }
));
assert_eq!(code.formatter().kind(), TemplateFormatterKind::LowerHex);
assert!(code.formatter().is_alternate());

let payload = placeholders.next().expect("payload placeholder");
assert_eq!(
Expand Down
9 changes: 8 additions & 1 deletion README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ assert_eq!(wrapped.to_string(), "I/O failed: disk offline");
- `TemplateFormatter` mirrors `thiserror`'s formatter detection so existing
derives that relied on hexadecimal, pointer or exponential renderers keep
compiling.
- `TemplateFormatterKind` exposes the formatter trait requested by a
placeholder, making it easy to branch on the requested rendering behaviour
without manually matching every enum variant.

#### Formatter traits

Expand Down Expand Up @@ -205,7 +208,9 @@ assert!(rendered.contains("upper=1.5625E-1"));
~~~

~~~rust
use masterror::error::template::{ErrorTemplate, TemplateFormatter};
use masterror::error::template::{
ErrorTemplate, TemplateFormatter, TemplateFormatterKind
};

let template = ErrorTemplate::parse("{code:#x} → {payload:?}").expect("parse");
let mut placeholders = template.placeholders();
Expand All @@ -215,6 +220,8 @@ assert!(matches!(
code.formatter(),
TemplateFormatter::LowerHex { alternate: true }
));
assert_eq!(code.formatter().kind(), TemplateFormatterKind::LowerHex);
assert!(code.formatter().is_alternate());

let payload = placeholders.next().expect("payload placeholder");
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion masterror-template/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "masterror-template"
version = "0.1.2"
version = "0.1.3"
rust-version = "1.90"
edition = "2024"
repository = "https://github.com/RAprogramm/masterror"
Expand Down
Loading
Loading