Skip to main content

nr_cif/
types.rs

1use fixedlength_format_parser::FixedLengthFormatParser;
2use getset::{Getters, MutGetters};
3
4#[derive(Debug, Clone, Getters, MutGetters)]
5pub struct CIFFile {
6    #[getset(get = "pub", get_mut = "pub(crate)")]
7    records: Vec<CIFRecord>,
8}
9
10impl CIFFile {
11    pub(crate) fn new() -> Self {
12        Self { records: vec![] }
13    }
14}
15
16#[derive(Debug, Clone, FixedLengthFormatParser)]
17pub enum CIFRecord {
18    #[record_type = "HD"]
19    Header {
20        #[field_starts = 2]
21        #[field_length = 20]
22        file_mainframe_identity: String,
23        #[field_length = 6]
24        date_of_extract: String,
25        #[field_length = 4]
26        time_of_extract: String,
27        #[field_length = 7]
28        current_file_reference: String,
29        #[field_length = 7]
30        last_file_reference: String,
31        #[field_length = 1]
32        update_indicator: char,
33        #[field_length = 1]
34        version: char,
35        #[field_length = 6]
36        user_start_date: String,
37        #[field_length = 6]
38        user_end_date: String,
39    },
40
41    #[record_type = "TI"]
42    TIPLOCInsert {
43        #[field_starts = 2]
44        #[field_length = 7]
45        tiploc: String,
46        #[field_length = 2]
47        capitals_identification: u8,
48        #[field_length = 6]
49        nlc: u32,
50        #[field_length = 1]
51        nlc_check_char: char,
52        #[field_length = 26]
53        tps_description: String,
54        #[field_length = 5]
55        stanox: u32,
56        #[field_length = 4]
57        po_mcp_code: String,
58        #[field_length = 3]
59        three_alpha_code: String,
60        #[field_length = 16]
61        nlc_description: String,
62    },
63
64    #[record_type = "TA"]
65    TIPLOCAmend {
66        #[field_starts = 2]
67        #[field_length = 7]
68        tiploc: String,
69        #[field_length = 2]
70        capitals_identification: u8,
71        #[field_length = 6]
72        nlc: u32,
73        #[field_length = 1]
74        nlc_check_char: char,
75        #[field_length = 26]
76        tps_description: String,
77        #[field_length = 5]
78        stanox: u32,
79        #[field_length = 4]
80        po_mcp_code: String,
81        #[field_length = 3]
82        three_alpha_code: String,
83        #[field_length = 16]
84        nlc_description: String,
85        #[field_length = 7]
86        new_tiploc: String,
87    },
88
89    #[record_type = "TD"]
90    TIPLOCDelete {
91        #[field_starts = 2]
92        #[field_length = 7]
93        tiploc: String,
94    },
95
96    #[record_type = "AA"]
97    Association {
98        #[field_starts = 2]
99        #[field_length = 1]
100        transaction_type: char,
101        #[field_length = 6]
102        main_train_uid: String,
103        #[field_length = 6]
104        associated_train_uid: String,
105        #[field_length = 6]
106        association_start_date: String,
107        #[field_length = 6]
108        association_end_date: String,
109        #[field_length = 7]
110        association_days: String,
111        #[field_length = 2]
112        association_category: String,
113        #[field_length = 1]
114        association_date_indicator: char,
115        #[field_length = 7]
116        association_location: String,
117        #[field_length = 1]
118        base_location_suffix: String,
119        #[field_length = 1]
120        association_location_suffix: String,
121        #[field_length = 1]
122        diagram_type: char,
123        #[field_length = 1]
124        association_type: char,
125        #[field_starts = 79]
126        #[field_length = 1]
127        stp_indicator: char,
128    },
129
130    #[record_type = "BS"]
131    BasicSchedule {
132        #[field_starts = 2]
133        #[field_length = 1]
134        transaction_type: char,
135        #[field_length = 6]
136        train_uid: String,
137        #[field_length = 6]
138        date_runs_from: String,
139        #[field_length = 6]
140        date_runs_to: String,
141        #[field_length = 7]
142        days_run: String,
143        #[field_length = 1]
144        bank_holiday_running: char,
145        #[field_length = 1]
146        train_status: char,
147        #[field_length = 2]
148        train_category: String,
149        #[field_length = 4]
150        train_identity: String,
151        #[field_length = 4]
152        headcode: String,
153        #[field_length = 1]
154        course_indicator: char,
155        #[field_length = 8]
156        train_service_code: String,
157        #[field_length = 1]
158        portion_id: char,
159        #[field_length = 3]
160        power_type: String,
161        #[field_length = 4]
162        timing_load: String,
163        #[field_length = 3]
164        speed: String,
165        #[field_length = 6]
166        operating_characteristics: String,
167        #[field_length = 1]
168        seating_class: char,
169        #[field_length = 1]
170        sleepers: char,
171        #[field_length = 1]
172        reservations: char,
173        #[field_length = 1]
174        connection_indicator: char,
175        #[field_length = 4]
176        catering_code: String,
177        #[field_length = 4]
178        service_branding: String,
179        #[field_starts = 79]
180        #[field_length = 1]
181        stp_indicator: char,
182    },
183
184    #[record_type = "BX"]
185    BasicScheduleExtended {
186        #[field_starts = 2]
187        #[field_length = 4]
188        traction_class: String,
189        #[field_length = 5]
190        uic_code: String,
191        #[field_length = 2]
192        atoc_code: String,
193        #[field_length = 1]
194        applicable_timetable_code: char,
195    },
196
197    #[record_type = "LO"]
198    LocationOrigin {
199        #[field_starts = 2]
200        #[field_length = 8]
201        location: String,
202        #[field_length = 5]
203        scheduled_departure_time: String,
204        #[field_length = 4]
205        public_departure_time: String,
206        #[field_length = 3]
207        platform: String,
208        #[field_length = 3]
209        line: String,
210        #[field_length = 2]
211        engineering_allowance: String,
212        #[field_length = 2]
213        pathing_allowance: String,
214        #[field_length = 12]
215        activity: String,
216        #[field_length = 2]
217        performance_allowance: String,
218    },
219
220    #[record_type = "LI"]
221    LocationIntermediate {
222        #[field_starts = 2]
223        #[field_length = 8]
224        location: String,
225        #[field_length = 5]
226        scheduled_arrival_time: String,
227        #[field_length = 5]
228        scheduled_departure_time: String,
229        #[field_length = 5]
230        scheduled_pass: String,
231        #[field_length = 4]
232        public_arrival_time: String,
233        #[field_length = 4]
234        public_departure_time: String,
235        #[field_length = 3]
236        platform: String,
237        #[field_length = 3]
238        line: String,
239        #[field_length = 3]
240        path: String,
241        #[field_length = 12]
242        activity: String,
243        #[field_length = 2]
244        engineering_allowance: String,
245        #[field_length = 2]
246        pathing_allowance: String,
247        #[field_length = 2]
248        performance_allowance: String,
249    },
250
251    #[record_type = "CR"]
252    ChangeEnRoute {
253        #[field_starts = 2]
254        #[field_length = 8]
255        location: String,
256        #[field_length = 2]
257        train_category: String,
258        #[field_length = 4]
259        train_identity: String,
260        #[field_length = 4]
261        headcode: String,
262        #[field_length = 1]
263        course_indicator: char,
264        #[field_length = 8]
265        profit_centre_code: String,
266        #[field_length = 1]
267        business_sector: char,
268        #[field_length = 3]
269        power_type: String,
270        #[field_length = 4]
271        timing_load: String,
272        #[field_length = 3]
273        speed: String,
274        #[field_length = 6]
275        operating_chars: String,
276        #[field_length = 1]
277        train_class: char,
278        #[field_length = 1]
279        sleepers: char,
280        #[field_length = 1]
281        reservations: char,
282        #[field_length = 1]
283        connect_indicator: char,
284        #[field_length = 4]
285        catering_code: String,
286        #[field_length = 4]
287        service_branding: String,
288        #[field_length = 4]
289        traction_class: String,
290        #[field_length = 5]
291        uic_code: String,
292        #[field_length = 8]
293        retail_train_id: String,
294    },
295
296    #[record_type = "LT"]
297    LocationTerminate {
298        #[field_starts = 2]
299        #[field_length = 8]
300        location: String,
301        #[field_length = 5]
302        scheduled_arrival_time: String,
303        #[field_length = 4]
304        public_arrival_time: String,
305        #[field_length = 3]
306        platform: String,
307        #[field_length = 3]
308        path: String,
309        #[field_length = 12]
310        activity: String,
311    },
312
313    #[record_type = "ZZ"]
314    Trailer,
315}