rxing/client/result/
VINParsedResult.rs1use super::{ParsedRXingResult, ParsedRXingResultType};
20
21#[derive(PartialEq, Eq, Hash, Debug)]
25pub struct VINParsedRXingResult {
26 vin: String,
27 world_manufacturer_id: String,
28 vehicle_descriptor_section: String,
29 vehicle_identifier_section: String,
30 country_code: String,
31 vehicle_attributes: String,
32 model_year: u32,
33 plant_code: char,
34 sequential_number: String,
35}
36
37impl ParsedRXingResult for VINParsedRXingResult {
38 fn getType(&self) -> super::ParsedRXingResultType {
39 ParsedRXingResultType::Vin
40 }
41
42 fn getDisplayRXingResult(&self) -> String {
43 let mut result = String::with_capacity(50);
44 result.push_str(&self.world_manufacturer_id);
45 result.push(' ');
46 result.push_str(&self.vehicle_descriptor_section);
47 result.push(' ');
48 result.push_str(&self.vehicle_identifier_section);
49 result.push('\n');
50 if !self.country_code.is_empty() {
51 result.push_str(&self.country_code);
52 result.push(' ');
53 }
54 result.push_str(&self.model_year.to_string());
55 result.push(' ');
56 result.push(self.plant_code);
57 result.push(' ');
58 result.push_str(&self.sequential_number);
59 result.push('\n');
60
61 result
62 }
63}
64impl VINParsedRXingResult {
65 #[allow(clippy::too_many_arguments)]
66 pub fn new(
67 vin: String,
68 world_manufacturer_id: String,
69 vehicle_descriptor_section: String,
70 vehicle_identifier_section: String,
71 country_code: String,
72 vehicle_attributes: String,
73 model_year: u32,
74 plant_code: char,
75 sequential_number: String,
76 ) -> Self {
77 Self {
78 vin,
79 world_manufacturer_id,
80 vehicle_descriptor_section,
81 vehicle_identifier_section,
82 country_code,
83 vehicle_attributes,
84 model_year,
85 plant_code,
86 sequential_number,
87 }
88 }
89
90 pub fn getVIN(&self) -> &str {
91 &self.vin
92 }
93
94 pub fn getWorldManufacturerID(&self) -> &str {
95 &self.world_manufacturer_id
96 }
97
98 pub fn getVehicleDescriptorSection(&self) -> &str {
99 &self.vehicle_descriptor_section
100 }
101
102 pub fn getVehicleIdentifierSection(&self) -> &str {
103 &self.vehicle_identifier_section
104 }
105
106 pub fn getCountryCode(&self) -> &str {
107 &self.country_code
108 }
109
110 pub fn getVehicleAttributes(&self) -> &str {
111 &self.vehicle_attributes
112 }
113
114 pub fn getModelYear(&self) -> u32 {
115 self.model_year
116 }
117
118 pub fn getPlantCode(&self) -> char {
119 self.plant_code
120 }
121
122 pub fn getSequentialNumber(&self) -> &str {
123 &self.sequential_number
124 }
125}