Description
Implement Base64String as a ValueObject in the primitives module.
Spec: valid base64-encoded string
Implementation checklist
Implementation detail
Input / Output
|
Type |
Alias |
| Input |
String |
Base64StringInput |
| Output |
String — the validated base64 string as-is |
Base64StringOutput |
Normalization
Trim surrounding whitespace.
Validation
- Must be valid standard Base64 (alphabet
A–Z, a–z, 0–9, +, /, with = padding).
- Validate using the
base64 crate (add as optional dependency to the primitives feature) — attempt to decode; if it succeeds the input is valid.
- Padding must be correct: length must be a multiple of 4 (after trimming).
Extra methods
decode() -> Vec<u8> — returns the decoded raw bytes. This operation always succeeds since construction already validates the encoding.
References
Description
Implement
Base64Stringas aValueObjectin theprimitivesmodule.Spec: valid base64-encoded string
Implementation checklist
src/primitives/base64string.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/primitives/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
StringBase64StringInputString— the validated base64 string as-isBase64StringOutputNormalization
Trim surrounding whitespace.
Validation
A–Z,a–z,0–9,+,/, with=padding).base64crate (add as optional dependency to theprimitivesfeature) — attempt to decode; if it succeeds the input is valid.Extra methods
decode() -> Vec<u8>— returns the decoded raw bytes. This operation always succeeds since construction already validates the encoding.References