Skip to content

Add #[repr(transparent)] + const to numeric enums#101

Closed
taiman724 wants to merge 1 commit into
bluecatengineering:masterfrom
taiman724:chore/repr-transparent-numeric-enums
Closed

Add #[repr(transparent)] + const to numeric enums#101
taiman724 wants to merge 1 commit into
bluecatengineering:masterfrom
taiman724:chore/repr-transparent-numeric-enums

Conversation

@taiman724

Copy link
Copy Markdown

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 with pub const values, following the exact pattern introduced by #99 (Architecture conversion, merged 2026-05-09).

Converted types

  • v4::HType, v4::Opcode, v4::NodeType, v4::MessageType, v4::bulk_query::QueryState, v4::bulk_query::Code
  • v6::HType, v6::MessageType, v6::Status

Intentionally excluded

v6::OptionCode, v6::OROCode, and v4::relay::RelayCode are 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, and cargo fmt --check all pass locally on Rust 1.90.0.


Prepared with AI assistance (Claude Sonnet 4.6 via Claude Code).

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>
@stappersg

stappersg commented May 13, 2026 via email

Copy link
Copy Markdown

@leshow

leshow commented May 14, 2026

Copy link
Copy Markdown
Collaborator

@stappersg please keep comments constructive. The repo has no official policy on LLM usage at the moment

@leshow

leshow commented May 25, 2026

Copy link
Copy Markdown
Collaborator

I did more or less the same thing but included the missing enums in #105

@leshow leshow closed this May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repr(transparent) + const on numeric enums

3 participants