Skip to content

Add ApiKey (net) #55

@vhrcgcom

Description

@vhrcgcom

Description

Implement ApiKey as a ValueObject in the net module.

Spec: non-empty; masked Display shows only last 4 chars

Implementation checklist

  • Create src/net/apikey.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/net/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 ApiKeyInput
Output String — the full key, stored internally ApiKeyOutput

Normalization

Trim.

Validation

  • Must not be empty after trimming.

Display

Display and masked() show only the last 4 characters, with the rest replaced by *. For keys shorter than 4 characters, mask all but the last character.

value() returns the full key — callers must treat this as sensitive data.

Extra methods

  • last_four() -> &str — the last 4 characters of the key.
  • masked() -> String — the masked representation, e.g. "********************abcd".

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions