Description
Implement Vin as a ValueObject in the identifiers module.
Spec: Vehicle Identification Number, 17 chars, checksum validated
Implementation checklist
Implementation detail
Input / Output
|
Type |
Alias |
| Input |
String |
VinInput |
| Output |
String |
VinOutput |
Normalization
Trim, convert to uppercase.
Validation
- Exactly 17 characters after normalising.
- Only ASCII letters and digits; the letters
I, O, and Q are forbidden (they are excluded from the VIN alphabet to avoid confusion with 1, 0, and 0).
- Check digit (position 9, 0-indexed) must be valid: each character has a transliteration value and a positional weight; compute weighted sum mod 11 and compare against the stored check digit (
0–9 or X for 10).
Extra methods
wmi() -> &str — World Manufacturer Identifier, first 3 characters.
vds() -> &str — Vehicle Descriptor Section, characters 4–9.
vis() -> &str — Vehicle Identifier Section, last 8 characters (includes model year and serial number).
model_year() -> char — character at position 10 (index 9), encodes the model year.
References
Description
Implement
Vinas aValueObjectin theidentifiersmodule.Spec: Vehicle Identification Number, 17 chars, checksum validated
Implementation checklist
src/identifiers/vin.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/identifiers/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
StringVinInputStringVinOutputNormalization
Trim, convert to uppercase.
Validation
I,O, andQare forbidden (they are excluded from the VIN alphabet to avoid confusion with1,0, and0).0–9orXfor 10).Extra methods
wmi() -> &str— World Manufacturer Identifier, first 3 characters.vds() -> &str— Vehicle Descriptor Section, characters 4–9.vis() -> &str— Vehicle Identifier Section, last 8 characters (includes model year and serial number).model_year() -> char— character at position 10 (index 9), encodes the model year.References