diff --git a/CHANGELOG.md b/CHANGELOG.md index bf01853..5cf7d29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. ## [0.10.7] - 2025-10-24 +### Fixed +- Published the shared template parser crate so `masterror-derive` no longer + depends on a workspace-only package when uploaded to crates.io. + +### Documentation +- Added a dedicated README for `masterror-template` describing installation, + parsing examples and formatter metadata for crates.io readers. ### Tests - Added regression coverage for long classifier needles to exercise the heap-allocation fallback. @@ -16,6 +23,8 @@ All notable changes to this project will be documented in this file. - Precomputed lowercase Turnkey classifier needles with a stack-backed buffer to remove repeated transformations while keeping the common zero-allocation path for short patterns. +- Bumped `masterror-derive` to `0.6.6` and `masterror-template` to `0.3.6` so + downstream users rely on the newly published parser crate. ## [0.10.6] - 2025-09-21 @@ -168,6 +177,12 @@ All notable changes to this project will be documented in this file. - Documented the `#[app_error(...)]` attribute in the README, outlining the struct and enum mapping patterns and the `message` flag behaviour. +## [0.6.6] - 2025-10-24 + +### Fixed +- Pointed the derive crate at the published `masterror-template` dependency so + `cargo publish` succeeds without private workspace patches. + ## [0.6.5] - 2025-10-12 ### Added @@ -465,6 +480,15 @@ All notable changes to this project will be documented in this file. ### Documentation - Documented browser/WASM support and console logging workflow in the README and crate docs. +## [0.3.6] - 2025-10-24 + +### Added +- Wrote a README for crates.io explaining installation and parser usage. + +### Fixed +- Removed the `publish = false` flag so the shared template parser can be + released alongside the derive crate. + ## [0.3.5] - 2025-09-12 ### Added - Conversion from `teloxide_core::RequestError` into `AppError` (feature `teloxide`). @@ -565,10 +589,19 @@ All notable changes to this project will be documented in this file. - **MSRV:** 1.89 - **No unsafe:** the crate forbids `unsafe`. +[0.10.7]: https://github.com/RAprogramm/masterror/releases/tag/v0.10.7 +[0.10.6]: https://github.com/RAprogramm/masterror/releases/tag/v0.10.6 +[0.6.6]: https://github.com/RAprogramm/masterror/releases/tag/v0.6.6 +[0.6.5]: https://github.com/RAprogramm/masterror/releases/tag/v0.6.5 +[0.6.4]: https://github.com/RAprogramm/masterror/releases/tag/v0.6.4 +[0.6.3]: https://github.com/RAprogramm/masterror/releases/tag/v0.6.3 +[0.6.2]: https://github.com/RAprogramm/masterror/releases/tag/v0.6.2 +[0.6.0]: https://github.com/RAprogramm/masterror/releases/tag/v0.6.0 [0.5.2]: https://github.com/RAprogramm/masterror/releases/tag/v0.5.2 [0.5.1]: https://github.com/RAprogramm/masterror/releases/tag/v0.5.1 [0.5.0]: https://github.com/RAprogramm/masterror/releases/tag/v0.5.0 [0.4.0]: https://github.com/RAprogramm/masterror/releases/tag/v0.4.0 +[0.3.6]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.6 [0.3.5]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.5 [0.3.4]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.4 [0.3.3]: https://github.com/RAprogramm/masterror/releases/tag/v0.3.3 diff --git a/Cargo.lock b/Cargo.lock index 3ad3692..a280190 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1636,7 +1636,7 @@ dependencies = [ [[package]] name = "masterror-derive" -version = "0.6.2" +version = "0.6.6" dependencies = [ "masterror-template", "proc-macro2", @@ -1646,7 +1646,7 @@ dependencies = [ [[package]] name = "masterror-template" -version = "0.3.1" +version = "0.3.6" [[package]] name = "matchit" diff --git a/Cargo.toml b/Cargo.toml index 21c8f5c..9cddd72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,8 +71,8 @@ turnkey = [] openapi = ["dep:utoipa"] [workspace.dependencies] -masterror-derive = { version = "0.6.2" } -masterror-template = { version = "0.3.1" } +masterror-derive = { version = "0.6.6" } +masterror-template = { version = "0.3.6" } [dependencies] masterror-derive = { version = "0.6" } diff --git a/README.md b/README.md index b376d9a..24b4ddf 100644 --- a/README.md +++ b/README.md @@ -709,4 +709,3 @@ MSRV = 1.90 (may raise in minor, never in patch). Apache-2.0 OR MIT, at your option. - diff --git a/masterror-derive/Cargo.toml b/masterror-derive/Cargo.toml index 3e23e98..c9ba1a6 100644 --- a/masterror-derive/Cargo.toml +++ b/masterror-derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "masterror-derive" rust-version = "1.90" -version = "0.6.2" +version = "0.6.6" edition = "2024" license = "MIT OR Apache-2.0" repository = "https://github.com/RAprogramm/masterror" diff --git a/masterror-template/Cargo.toml b/masterror-template/Cargo.toml index 62bc80b..7ceec57 100644 --- a/masterror-template/Cargo.toml +++ b/masterror-template/Cargo.toml @@ -1,12 +1,11 @@ [package] name = "masterror-template" -version = "0.3.1" +version = "0.3.6" rust-version = "1.90" edition = "2024" repository = "https://github.com/RAprogramm/masterror" readme = "README.md" description = "Template utilities for masterror and its derive macros" -publish = false license = "MIT OR Apache-2.0" [dependencies] diff --git a/masterror-template/README.md b/masterror-template/README.md new file mode 100644 index 0000000..e1c15ff --- /dev/null +++ b/masterror-template/README.md @@ -0,0 +1,81 @@ +# masterror-template + +`masterror-template` packages the template parser shared by the [`masterror`][masterror] runtime crate and the [`masterror-derive`][derive] procedural macros. It understands the `#[error("...")]` formatting language popularised by `thiserror` v2, producing a structured representation that downstream code can inspect or render. + +The crate is intentionally small: it exposes just enough API for advanced applications that want to inspect derived error displays, implement custom derive helpers, or perform static analysis over formatting placeholders. + +## Installation + +Add the crate alongside `masterror` if you need direct access to the parser: + +```toml +[dependencies] +masterror-template = { version = "0.3.6" } +``` + +`masterror-template` targets Rust 1.90 and builds on stable and nightly toolchains alike. + +## Parsing templates + +Call [`ErrorTemplate::parse`](https://docs.rs/masterror-template/latest/masterror_template/template/struct.ErrorTemplate.html#method.parse) to turn an `&str` into a structured template: + +```rust +use masterror_template::template::{ErrorTemplate, TemplateIdentifier}; + +fn inspect(template: &str) { + let parsed = ErrorTemplate::parse(template).expect("valid template"); + + for placeholder in parsed.placeholders() { + match placeholder.identifier() { + TemplateIdentifier::Named(name) => println!("named placeholder: {name}"), + TemplateIdentifier::Positional(index) => println!("positional placeholder: {index}"), + TemplateIdentifier::Implicit(index) => println!("implicit placeholder: {index}"), + } + } +} +``` + +The parser preserves literal text and exposes every placeholder with span metadata, making it straightforward to surface diagnostics or transform templates programmatically. + +## Formatter metadata + +Each [`TemplatePlaceholder`](https://docs.rs/masterror-template/latest/masterror_template/template/struct.TemplatePlaceholder.html) advertises the requested formatter through [`TemplateFormatter`](https://docs.rs/masterror-template/latest/masterror_template/template/enum.TemplateFormatter.html) and [`TemplateFormatterKind`](https://docs.rs/masterror-template/latest/masterror_template/template/enum.TemplateFormatterKind.html): + +```rust +use masterror_template::template::{ErrorTemplate, TemplateFormatterKind}; + +let template = ErrorTemplate::parse("{value:#x}").expect("parse"); +let placeholder = template.placeholders().next().expect("placeholder"); +let formatter = placeholder.formatter(); +assert_eq!(formatter.kind(), TemplateFormatterKind::LowerHex); +assert!(formatter.is_alternate()); +``` + +This mirrors the formatting traits accepted by `core::fmt`, enabling consumers to route values through `Display`, `Debug`, hexadecimal, binary, pointer, or exponential renderers. + +## Error reporting + +Parsing failures produce [`TemplateError`](https://docs.rs/masterror-template/latest/masterror_template/template/enum.TemplateError.html) variants with precise byte ranges. The metadata simplifies IDE integrations and procedural macros that need to point at the offending part of the template. + +```rust +use masterror_template::template::ErrorTemplate; + +let err = ErrorTemplate::parse("{foo").unwrap_err(); +assert!(matches!(err, masterror_template::template::TemplateError::UnterminatedPlaceholder { .. })); +``` + +## License + +Dual licensed under either of + +- Apache License, Version 2.0, ([LICENSE-APACHE](../LICENSE-APACHE) or ) +- MIT license ([LICENSE-MIT](../LICENSE-MIT) or ) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[masterror]: https://crates.io/crates/masterror +[derive]: https://crates.io/crates/masterror-derive