Add #[repr(transparent)] + const to numeric enums#101
Closed
taiman724 wants to merge 1 commit into
Closed
Conversation
Convert numeric enum types (HType, Opcode, NodeType, MessageType, QueryState, Code, Status) from traditional enums with Unknown(n) fallback variants to #[repr(transparent)] newtype structs with associated const values. This follows the pattern introduced for Architecture in bluecatengineering#99, making the codebase consistent before the next release. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
On Tue, May 12, 2026 at 07:10:53PM -0700, shunta hayashi wrote:
....
Prepared with AI assistance (Claude Sonnet 4.6 via Claude Code).
and made my eyes bleed
|
Collaborator
|
@stappersg please keep comments constructive. The repo has no official policy on LLM usage at the moment |
Collaborator
|
I did more or less the same thing but included the missing enums in #105 |
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
Closes #100. Converts 9 numeric enum types from the traditional
enum E { Variant, ..., Unknown(uN) }pattern to#[repr(transparent)] pub struct E(pub uN)newtype structs withpub constvalues, following the exact pattern introduced by #99 (Architectureconversion, merged 2026-05-09).Converted types
v4::HType,v4::Opcode,v4::NodeType,v4::MessageType,v4::bulk_query::QueryState,v4::bulk_query::Codev6::HType,v6::MessageType,v6::StatusIntentionally excluded
v6::OptionCode,v6::OROCode, andv4::relay::RelayCodeare used in hundreds of pattern-match arms across decode logic (369 call sites vs 30 for the converted types). They would require a separate, larger refactor and are left for a follow-up PR.Verification
cargo build --all-features,cargo test --all-features(55 unit + 18 doc tests),cargo clippy --all-targets -- -D warnings, andcargo fmt --checkall pass locally on Rust 1.90.0.Prepared with AI assistance (Claude Sonnet 4.6 via Claude Code).