Description
Implement Domain as a ValueObject in the net module.
Spec: valid domain name without scheme
Implementation checklist
Implementation detail
Input / Output
|
Type |
Alias |
| Input |
String |
DomainInput |
| Output |
String — lowercase |
DomainOutput |
Normalization
Trim, convert to lowercase.
Validation
- Must not contain a scheme (
:// is forbidden — it is a hostname, not a URL).
- Each label (segment between dots) must be 1–63 characters.
- Labels may only contain ASCII letters, digits, and hyphens; no leading or trailing hyphen per label.
- At least one dot (single-label names like
"localhost" are rejected).
- Total length must not exceed 253 characters.
Extra methods
tld() -> &str — the last label after the final dot, e.g. "com", "cz".
References
Description
Implement
Domainas aValueObjectin thenetmodule.Spec: valid domain name without scheme
Implementation checklist
src/net/domain.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/net/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
StringDomainInputString— lowercaseDomainOutputNormalization
Trim, convert to lowercase.
Validation
://is forbidden — it is a hostname, not a URL)."localhost"are rejected).Extra methods
tld() -> &str— the last label after the final dot, e.g."com","cz".References