Description
Implement ApiKey as a ValueObject in the net module.
Spec: non-empty; masked Display shows only last 4 chars
Implementation checklist
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
Description
Implement
ApiKeyas aValueObjectin thenetmodule.Spec: non-empty; masked
Displayshows only last 4 charsImplementation checklist
src/net/apikey.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/net/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
StringApiKeyInputString— the full key, stored internallyApiKeyOutputNormalization
Trim.
Validation
Display
Displayandmasked()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