Skip to content

Conversation

@RAprogramm
Copy link
Owner

Summary

  • replace AppCode enum with a validated string-backed newtype and expose AppCode::new/AppCode::try_new
  • update error conversions, mappings, docs, and templates to accept caller-defined codes while preserving built-in constants
  • refresh trybuild fixtures and add regression tests covering dynamic code round-trips

Testing

  • cargo +nightly fmt --check
  • cargo +nightly clippy --all-targets -- -D warnings
  • cargo +nightly build --all-targets
  • cargo +nightly test --all
  • cargo +nightly doc --no-deps
  • cargo audit
  • cargo deny check

https://chatgpt.com/codex/tasks/task_e_68d6843a9710832bbc90c2d9af8492ab

@RAprogramm RAprogramm merged commit ef44371 into new_verison Sep 26, 2025
1 of 2 checks passed
@RAprogramm RAprogramm deleted the eye-of-ra/refactor-appcode-to-support-caller-defined-codes branch September 26, 2025 13:18
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ 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

Comment on lines +45 to +53
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AppCode {
repr: CodeRepr
}

/// Database-related failure (query, connection, migration, etc.).
///
/// Typically mapped to HTTP **500 Internal Server Error**.
Database,
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum CodeRepr {
Static(&'static str),
Owned(Box<str>)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Normalize AppCode equality across static and dynamic instances

Equality for AppCode currently derives from the CodeRepr enum, so codes backed by a static literal (CodeRepr::Static) never compare equal to dynamically constructed codes (CodeRepr::Owned) even when their textual representation matches. As a result, code lookups such as mapping_for_code(&AppCode::try_new("NOT_FOUND").unwrap()) fall through to the default mapping instead of returning the NOT_FOUND mapping, and any HashMap keyed by AppCode will treat equivalent codes as distinct keys. Equality (and hashing) should be based on as_str() rather than the storage variant so that custom codes created via try_new behave identically to built‑in constants.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants