Repository navigation
refactor(elements)!: one SimpleDecoder replaces the 67 decoder types 15 copies of simple_decoder! generated - #894
Merged
Merged
Conversation
…15 copies of simple_decoder! generated
DrunkOnJava
marked this pull request as ready for review
October 23, 2026 11:50
Owner
Author
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e623af4e5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
# Conflicts: # CHANGELOG.md
…turns a reference into it
3 of 4 tasks
8 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
macro_rules! simple_decoderwas defined 15 times, byte-for-byte identical, once per element file, and each of its 67 expansions was a public unit struct plus anElementDecoderimpl. One documented type,elements::SimpleDecoder { class_name }, now does the same job, and the registry listsSimpleDecoder::new("<class>")for each of those 67 classes. No macro remains.Motivation
Found by the 2026-10-23 style audit (Google Rust style guide, "Macros": prefer types to macros; and the 67 generated structs had no docs, a large share of the crate's undocumented public items). The element modules are stable API under #873, so this belongs before 1.0.
Changes
src/elements/simple_decoder.rs(new):SimpleDecoder, with the macro's exactdecode/decode_with_limitsbehaviour (wrong-schema refusal,decode_instance_with_limitsat offset 0).src/elements/mod.rs:pub use simple_decoder::SimpleDecoder;; the 67 registry entries becomeBox::new(SimpleDecoder::new("<class>")), same classes, same order. Module docs say how to register a simple class.src/elements/mep.rs: the coverage table names the registration.templates/element-decoder/: registers throughSimpleDecoder; no longer generates unit tests (banned in this repository), and the README's step 3 asks for a real-file check instead.CHANGELOG.md: a breaking Changed entry.Testing
No unit tests (banned). The decode path is identical, so the evidence is CI plus Measure:
iter_elements_typed)Audit-honesty checklist
Legal and contribution hygiene
Breaking changes
The 67 unit types (
mep::DuctDecoder,generic::MassDecoder, ...) are gone;SimpleDecoder::new("Duct")decodes whatmep::DuctDecoderdid. The wrong-schema error text changes to<class> decoder received wrong schema: ....Screenshots or output samples
N/A: no output change.