Skip to content

Add HexColor (primitives) #73

Description

@vhrcgcom

Description

Implement HexColor as a ValueObject in the primitives module.

Spec: #RRGGBB or #RGB, normalised to uppercase

Implementation checklist

  • Create src/primitives/hexcolor.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/primitives/mod.rs and prelude
  • Unit tests: valid input · empty input · invalid format · normalisation
  • Doc comment with # Example block
  • Update status in ROADMAP.md from ⬜ to ✅

Implementation detail

Input / Output

Type Alias
Input String HexColorInput
Output String — always 7-character #RRGGBB uppercase HexColorOutput

Normalization

Trim; uppercase; expand 3-digit shorthand to 6-digit form (#F0A → #FF00AA by doubling each hex digit).

Validation

  • Must start with #.
  • Remaining characters must be exactly 3 or 6 hexadecimal digits (0–9, A–F after uppercasing).

Extra methods

  • r() -> u8 — red channel value (0–255).
  • g() -> u8 — green channel value (0–255).
  • b() -> u8 — blue channel value (0–255).

References

Activity

  1. changed the title [-]feat(primitives): HexColor[/-] [+]Add HexColor (primitives)[/+] on Apr 17, 2026
  2. linked a pull request that will close this issueAdd primitives module (v0.3.0) #84on Apr 20, 2026
  3. added a commit that references this issue on Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions