1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
use std::str::FromStr;

use crate::ParseError;

use super::*;
use edifact_types_macros::DisplayInnerSegment;
use serde::{Deserialize, Serialize};

/// BGM - BEGINNING OF MESSAGE
///
/// To indicate the type and function of a message and to
/// transmit the identifying number.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Bgm {
    pub _010: Option<C002>,
    /// 1004 - Document/message number
    ///
    /// Reference number assigned to the document/message by the issuer.
    /// an..35
    pub _020: Option<String>,
    pub _030: Option<_1225>,
    pub _040: Option<_4343>,
}

impl FromStr for Bgm {
    type Err = ParseError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let x = s.trim_end_matches('\'');
        let parts: Vec<&str> = x.split('+').collect();
        if parts[0] == "BGM" {
            if parts.len() > 5 {
                Err(ParseError {
                    msg: "too many segments".to_string(),
                })
            } else {
                let mut bgm = Bgm::default();
                if let Some(val) = parts.get(1) {
                    bgm._010 = Some(C002::from_str(val).unwrap());
                };
                if let Some(val) = parts.get(2) {
                    bgm._020 = Some(val.to_string());
                };
                if let Some(val) = parts.get(3) {
                    let t = _1225::from_str(val).unwrap();
                    bgm._030 = Some(t);
                };
                if let Some(val) = parts.get(4) {
                    let t = _4343::from_str(val).unwrap();
                    bgm._040 = Some(t);
                };
                Ok(bgm)
            }
        } else {
            Err(ParseError {
                msg: "segment name wrong".to_string(),
            })
        }
    }
}

/// C002 - DOCUMENT/MESSAGE NAME
#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Eq, Clone, DisplayInnerSegment)]
pub struct C002 {
    pub _010: Option<String>,
    pub _020: Option<String>,
    pub _030: Option<String>,
    pub _040: Option<String>,
}

impl FromStr for C002 {
    type Err = ParseError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let parts: Vec<&str> = s.split(':').collect();
        if parts.len() > 4 {
            Err(ParseError {
                msg: "too many segments".to_string(),
            })
        } else {
            Ok(C002 {
                _010: parts.first().map(|x| x.to_string()),
                _020: parts.get(1).map(|x| x.to_string()),
                _030: parts.get(2).map(|x| x.to_string()),
                _040: parts.get(3).map(|x| x.to_string()),
            })
        }
    }
}

/// C040 - CARRIER
///
/// Identification of a carrier by code and/or by name. Code
/// preferred.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C040 {
    /// Carrier identification
    ///
    /// C  an..17
    pub _010: Option<String>,
    /// Code list qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
    /// Code list responsible agency, coded
    ///
    /// C  an..3
    pub _030: Option<String>,
    /// Carrier name
    ///
    /// C  an..35
    pub _040: Option<String>,
}

/// C056 - DEPARTMENT OR EMPLOYEE DETAILS
///
/// Code and/or name of a department or employee. Code
/// preferred.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C056 {
    /// Department or employee identification
    ///
    /// C  an..17
    pub _010: Option<String>,
    /// Department or employee
    ///
    /// C  an..35
    pub _020: Option<String>,
}

/// C058 - NAME AND ADDRESS
///
/// Unstructured name and address: one to five lines.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C058 {
    /// Name and address line
    ///
    /// M  an..35
    pub _010: String,
    /// Name and address line
    ///
    /// C  an..35
    pub _020: Option<String>,
    /// Name and address line
    ///
    /// C  an..35
    pub _030: Option<String>,
    /// Name and address line
    ///
    /// C  an..35
    pub _040: Option<String>,
    /// Name and address line
    ///
    /// C  an..35
    pub _050: Option<String>,
}

/// C059 - STREET
///
/// Street address and/or PO Box number in a structured
/// address: one to three lines.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C059 {
    /// Street and number/p.o. box
    ///
    /// M  an..35
    pub _010: String,
    /// Street and number/p.o. box
    ///
    /// C  an..35
    pub _020: Option<String>,
    /// Street and number/p.o. box
    ///
    /// C  an..35
    pub _030: Option<String>,
}

/// C080 - PARTY NAME
///
/// Identification of a transaction party by name, one to five
/// lines. Party name may be formatted.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C080 {
    /// Party name
    ///
    /// M  an..35
    pub _010: String,
    /// Party name
    ///
    /// C  an..35
    pub _020: Option<String>,
    /// Party name
    ///
    /// C  an..35
    pub _030: Option<String>,
    /// Party name
    ///
    /// C  an..35
    pub _040: Option<String>,
    /// Party name
    ///
    /// C  an..35
    pub _050: Option<String>,
    /// Party name format, coded
    ///
    /// C  an..3
    pub _060: Option<String>,
}

/// C082  PARTY IDENTIFICATION DETAILS
///
/// Identification of a transaction party by code.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C082 {
    /// Party id. identification
    ///
    /// M  an..35
    pub _010: String,
    /// Code list qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
    /// Code list responsible agency, coded
    ///
    /// C  an..3
    pub _030: Option<String>,
}

/// C107 - TEXT REFERENCE
///
/// Coded reference to a standard text and its source.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C107 {
    /// Free text, coded
    ///
    /// M  an..3
    pub _010: String,
    /// Code list qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
    /// Code list responsible agency, coded
    ///
    /// C  an..3
    pub _030: Option<String>,
}

/// C108 - TEXT LITERAL
///
/// Free text; one to five lines.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C108 {
    /// Free text
    ///
    /// M  an..70
    pub _010: String,
    /// Free text
    ///
    /// C  an..70
    pub _020: Option<String>,
    /// Free text
    ///
    /// C  an..70
    pub _030: Option<String>,
    /// Free text
    ///
    /// C  an..70
    pub _040: Option<String>,
    /// Free text
    ///
    /// C  an..70
    pub _050: Option<String>,
}

/// C174 - VALUE/RANGE
///
/// Measurement value and relevant minimum and maximum
/// tolerances in that order.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C174 {
    /// Measure unit qualifier
    ///
    /// M  an..3
    pub _010: String,
    /// Measurement value
    ///
    /// C  n..18
    pub _020: Option<String>,
    /// Range minimum
    ///
    /// C  n..18
    pub _030: Option<String>,
    /// Range maximum
    ///
    /// C  n..18
    pub _040: Option<String>,
    /// Significant digits
    ///
    /// C  n..2
    pub _050: Option<String>,
}

/// C205 - HAZARD CODE
///
/// The identification of the dangerous goods in code.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C205 {
    /// Hazard code identification                        M  an..7
    pub _010: String,
    /// Hazard substance/item/page number                 C  an..7
    pub _020: Option<String>,
    /// Hazard code version number                        C  an..10
    pub _030: Option<String>,
}

/// C211 - DIMENSIONS
///
/// Specification of the dimensions of a transportable unit.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C211 {
    /// Measure unit qualifier
    ///
    /// M  an..3
    pub _010: String,
    /// Length dimension
    ///
    /// C  n..15
    pub _020: Option<String>,
    /// Width dimension
    ///
    /// C  n..15
    pub _030: Option<String>,
    /// Height dimension
    ///
    /// C  n..15
    pub _040: Option<String>,
}

/// C215 - SEAL ISSUER
///
/// Identification of the issuer of a seal on equipment either
/// by code or by name.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C215 {
    /// Sealing party, coded
    ///
    /// C  an..3
    pub _010: Option<String>,
    /// Code list qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
    /// Code list responsible agency, coded
    ///
    /// C  an..3
    pub _030: Option<String>,
    /// Sealing party
    ///
    /// C  an..35
    pub _040: Option<String>,
}

/// C219 - MOVEMENT TYPE
///
/// Description of type of service for movement of cargo.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C219 {
    /// Movement type, coded
    ///
    /// C  an..3
    pub _010: Option<String>,
    /// Movement type
    ///
    /// C  an..35
    pub _020: Option<String>,
}

/// C220 - MODE OF TRANSPORT
///
/// Method of transport code or name. Code preferred.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C220 {
    /// Mode of transport, coded
    ///
    /// C  an..3
    pub _010: Option<String>,
    /// Mode of transport
    ///
    /// C  an..17
    pub _020: Option<String>,
}

/// C222 - TRANSPORT IDENTIFICATION
///
/// Code and/or name identifying the means of transport.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C222 {
    /// Id. of means of transport identification
    ///
    /// C  an..9
    pub _010: Option<String>,
    /// Code list qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
    /// Code list responsible agency, coded
    ///
    /// C  an..3
    pub _030: Option<String>,
    /// Id. of the means of transport
    ///
    /// C  an..35
    pub _040: Option<String>,
    /// Nationality of means of transport, coded
    ///
    /// C  an..3
    pub _050: Option<String>,
}

/// C223 - DANGEROUS GOODS SHIPMENT FLASHPOINT
///
/// Temperature at which a vapor according to ISO 1523/73 can
/// be ignited.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C223 {
    /// Shipment flashpoint
    ///
    /// C  n3
    pub _010: Option<String>,
    /// Measure unit qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
}

/// C224 - EQUIPMENT SIZE AND TYPE
///
/// Code and/or name identifying size and type of equipment
/// used in transport. Code preferred.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C224 {
    /// Equipment size and type identification
    ///
    /// C  an..10
    pub _010: Option<String>,
    /// Code list qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
    /// Code list responsible agency, coded
    ///
    /// C  an..3
    pub _030: Option<String>,
    /// Equipment size and type
    ///
    /// C  an..35
    pub _040: Option<String>,
}

/// C228 - TRANSPORT MEANS
///
/// Code and/or name identifying the type of means of
/// transport.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C228 {
    /// Type of means of transport identification
    ///
    /// C  an..8
    pub _010: Option<String>,
    /// Type of means of transport
    ///
    /// C  an..17
    pub _020: Option<String>,
}

/// C234 - UNDG INFORMATION
///
/// Information on United Nations Dangerous Goods
/// classification.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C234 {
    /// UNDG number
    ///
    /// C  n4
    pub _010: Option<String>,
    /// Dangerous goods flashpoint
    ///
    /// C  an..8
    pub _020: Option<String>,
}

/// C235 - HAZARD IDENTIFICATION
///
/// Identification of the Orange placard required on the means
/// of transport.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C235 {
    /// Hazard identification number, upper part
    ///
    /// C  an..4
    pub _010: Option<String>,
    /// Substance identification number, lower part
    ///
    /// C  an4
    pub _020: Option<String>,
}

/// C236 - DANGEROUS GOODS LABEL
///
/// Markings identifying the type of hazardous goods and
/// similar information.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C236 {
    /// Dangerous goods label marking                     C  an..4
    pub _010: Option<String>,
    /// Dangerous goods label marking                     C  an..4
    pub _020: Option<String>,
    /// Dangerous goods label marking                     C  an..4
    pub _030: Option<String>,
}

/// C237 - EQUIPMENT IDENTIFICATION
///
/// Marks (letters and/or numbers) identifying equipment used
/// for transport such as a container.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C237 {
    /// Equipment identification number
    ///
    /// C  an..17
    pub _010: Option<String>,
    /// Code list qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
    /// Code list responsible agency, coded
    ///
    /// C  an..3
    pub _030: Option<String>,
    /// Country, coded
    ///
    /// C  an..3
    pub _040: Option<String>,
}

/// C239 - TEMPERATURE SETTING
///
/// The temperature under which the goods are (to be) stored
/// or shipped.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C239 {
    /// Temperature setting                               C  n3
    pub _010: Option<String>,
    /// Measure unit qualifier                            C  an..3
    pub _020: Option<String>,
}

/// C270 - CONTROL
///
/// Control total for checking integrity of a message or part
/// of a message.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C270 {
    /// Control qualifier
    ///
    /// M  an..3
    pub _010: String,
    /// Control value
    ///
    /// M  n..18
    pub _020: String,
    /// Measure unit qualifier
    ///
    /// C  an..3
    pub _030: Option<String>,
}

/// C280 - RANGE
///
/// Range minimum and maximum limits.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C280 {
    /// Measure unit qualifier                            M  an..3
    pub _010: String,
    /// Range minimum                                     C  n..18
    pub _020: Option<String>,
    /// Range maximum                                     C  n..18
    pub _030: Option<String>,
}

/// C401 - EXCESS TRANSPORTATION INFORMATION
///
/// To provide details of reason for, and responsibility for,
/// use of transportation other than normally utilized.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C401 {
    /// Excess transportation reason, coded
    ///
    /// M  an..3
    pub _010: String,
    /// Excess transportation responsibility, coded
    ///
    /// M  an..3
    pub _020: String,
    /// Customer authorization number
    ///
    /// C  an..17
    pub _030: Option<String>,
}

/// C502 - MEASUREMENT DETAILS
///
/// Identification of measurement type.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C502 {
    /// Measurement dimension, coded                      C  an..3
    pub _010: Option<String>,
    /// Measurement significance, coded                   C  an..3
    pub _020: Option<String>,
    /// Measurement attribute, coded                      C  an..3
    pub _030: Option<String>,
    /// Measurement attribute                             C  an..70
    pub _040: Option<String>,
}

/// C506 - REFERENCE
///
/// Identification of a reference.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C506 {
    /// Reference qualifier
    ///
    /// M  an..3
    pub _010: String,
    /// Reference number
    ///
    /// C  an..35
    pub _020: Option<String>,
    /// Line number
    ///
    /// C  an..6
    pub _030: Option<String>,
    /// Reference version number
    ///
    /// C  an..35
    pub _040: Option<String>,
}

/// C507 - DATE/TIME/PERIOD
///
/// Date and/or time, or period relevant to the specified
/// date/time/period type.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C507 {
    pub _010: String,
    pub _020: Option<String>,
    pub _030: Option<String>,
}

/// C517 - LOCATION IDENTIFICATION
///
/// Identification of a location by code or name.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C517 {
    /// Place/location identification
    ///
    /// C  an..25
    pub _010: Option<String>,
    /// Code list qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
    /// Code list responsible agency, coded
    ///
    /// C  an..3
    pub _030: Option<String>,
    /// Place/location
    ///
    /// C  an..17
    pub _040: Option<String>,
}

/// C519 - RELATED LOCATION ONE IDENTIFICATION
///
/// Identification the first related location by code or name.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C519 {
    /// Related place/location one identification
    ///
    /// C  an..25
    pub _010: Option<String>,
    /// Code list qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
    /// Code list responsible agency, coded
    ///
    /// C  an..3
    pub _030: Option<String>,
    /// Related place/location one
    ///
    /// C  an..70
    pub _040: Option<String>,
}

/// C523 - NUMBER OF UNIT DETAILS
///
/// Identification of number of units and its purpose.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C523 {
    /// Number of units                                   C  n..15
    pub _010: Option<String>,
    /// Number of units qualifier                         C  an..3
    pub _020: Option<String>,
}

/// C553 - RELATED LOCATION TWO IDENTIFICATION
///
/// Identification of second related location by code or name.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct C553 {
    /// Related place/location two identification
    ///
    /// C  an..25
    pub _010: Option<String>,
    /// Code list qualifier
    ///
    /// C  an..3
    pub _020: Option<String>,
    /// Code list responsible agency, coded
    ///
    /// C  an..3
    pub _030: Option<String>,
    /// Related place/location two
    ///
    /// C  an..70
    pub _040: Option<String>,
}

/// CNT - CONTROL TOTAL
///
/// To provide control total.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Cnt {
    /// CONTROL
    pub _010: C270,
}

/// CTA    CONTACT INFORMATION
///
/// To identify a person or a department to whom
/// communication should be directed.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Cta {
    /// CONTACT FUNCTION, CODED
    ///
    /// C  an..3
    pub _010: Option<String>,
    /// DEPARTMENT OR EMPLOYEE DETAILS
    pub _020: Option<C056>,
}

/// DGS - DANGEROUS GOODS
///
/// To identify dangerous goods.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Dgs {
    /// DANGEROUS GOODS REGULATIONS, CODED
    ///
    /// C  an..3
    pub _010: Option<String>,
    /// HAZARD CODE
    pub _020: Option<C205>,
    /// UNDG INFORMATION
    pub _030: Option<C234>,
    /// DANGEROUS GOODS SHIPMENT FLASHPOINT
    pub _040: Option<C223>,
    /// PACKING GROUP, CODED
    ///
    /// C  an..3
    pub _050: Option<String>,
    /// EMS NUMBER
    ///
    /// C  an..6
    pub _060: Option<String>,
    /// MFAG
    ///
    /// C  an..4
    pub _070: Option<String>,
    /// TREM CARD NUMBER
    ///
    /// C  an..10
    pub _080: Option<String>,
    /// HAZARD IDENTIFICATION
    pub _090: Option<C235>,
    /// DANGEROUS GOODS LABEL
    pub _100: Option<C236>,
    /// PACKING INSTRUCTION, CODED
    ///
    /// C  an..3
    pub _110: Option<String>,
    /// CATEGORY OF MEANS OF TRANSPORT, CODED
    ///
    /// C  an..3
    pub _120: Option<String>,
    /// PERMISSION FOR TRANSPORT, CODED
    ///
    /// C  an..3
    pub _130: Option<String>,
}

/// DIM - DIMENSIONS
///
/// To specify dimensions.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Dim {
    /// DIMENSION QUALIFIER
    ///
    /// M  an..3
    pub _010: String,
    /// DIMENSIONS
    pub _020: C211,
}

/// DTM - DATE/TIME/PERIOD
///
/// To specify date, and/or time, or period.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Dtm {
    /// DATE/TIME/PERIOD
    pub _010: C507,
}

/// EQA - ATTACHED EQUIPMENT
///
/// To specify attached or related equipment.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Eqa {
    /// EQUIPMENT QUALIFIER
    ///
    /// M  an..3
    pub _010: String,
    /// EQUIPMENT IDENTIFICATION
    pub _020: Option<C237>,
}

/// EQD - EQUIPMENT DETAILS
///
/// To identify a unit of equipment.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Eqd {
    /// EQUIPMENT QUALIFIER
    ///
    /// M  an..3
    pub _010: String,
    /// EQUIPMENT IDENTIFICATION
    pub _020: Option<C237>,
    /// EQUIPMENT SIZE AND TYPE
    pub _030: Option<C224>,
    /// EQUIPMENT SUPPLIER, CODED
    ///
    /// C  an..3
    pub _040: Option<String>,
    /// EQUIPMENT STATUS, CODED
    ///
    /// C  an..3
    pub _050: Option<String>,
    /// FULL/EMPTY INDICATOR, CODED
    ///
    /// C  an..3
    pub _060: Option<String>,
}

/// EQN - NUMBER OF UNITS
///
/// To specify the number of units.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Eqn {
    /// NUMBER OF UNIT DETAILS
    pub _010: C523,
}

/// FTX - Free Text
///
/// To provide free form or coded text information.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Ftx {
    /// TEXT SUBJECT QUALIFIER
    ///
    /// M  an..3
    pub _010: String,
    /// TEXT FUNCTION, CODED
    ///
    /// C  an..3
    pub _020: Option<String>,
    pub _030: Option<C107>,
    pub _040: Option<C108>,
    /// LANGUAGE, CODED
    ///
    /// C  an..3
    pub _050: Option<String>,
}

/// MEA - MEASUREMENTS
///
/// To specify physical measurements, including dimension
/// tolerances, weights and counts.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Mea {
    /// MEASUREMENT APPLICATION QUALIFIER                     M  an..3
    pub _010: String,
    /// MEASUREMENT DETAILS                                   C  
    pub _020: Option<C502>,
    /// VALUE/RANGE                                           C  
    pub _030: Option<C174>,
    /// SURFACE/LAYER INDICATOR, CODED                        C  an..3
    pub _040: Option<String>,
}

/// LOC - PLACE/LOCATION IDENTIFICATION
///
/// To identify a country/place/location/related location
/// one/related location two.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Loc {
    pub _010: String,
    pub _020: C517,
    pub _030: C519,
    pub _040: C553,
    /// RELATION, CODED
    ///
    /// C  an..3
    pub _050: Option<String>,
}

/// NAD - NAME AND ADDRESS
///
/// To specify the name/address and their related
/// function, either by CO82 only and/or unstructured by
/// CO58 or structured by CO80 thru 3207.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Nad {
    pub _010: String,
    pub _020: Option<C082>,
    pub _030: Option<C058>,
    pub _040: Option<C080>,
    pub _050: Option<C059>,
    pub _060: Option<String>,
    pub _070: Option<String>,
    pub _080: Option<String>,
    pub _090: Option<String>,
}

/// RFF - REFERENCE
///
/// To specify a reference.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Rff {
    // REFERENCE
    pub _010: C506,
}

/// RNG - RANGE DETAILS
///
/// To identify a range.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Rng {
    /// RANGE TYPE QUALIFIER
    ///
    /// M  an..3
    pub _010: String,
    /// RANGE
    pub _020: Option<C280>,
}

/// MESSAGE IDENTIFIER
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct S009 {
    /// Message type
    ///
    /// M  an..6
    pub _010: String,
    /// Message version number
    ///
    /// M  an..3
    pub _020: String,
    /// Message release number
    ///
    /// M  an..3
    pub _030: String,
    /// Controlling agency
    ///
    /// M  an..2
    pub _040: String,
    /// Association assigned code
    ///
    /// C  an..6
    pub _050: Option<String>,
}

/// STATUS OF THE TRANSFER
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayInnerSegment)]
pub struct S010 {
    /// Sequence of transfers
    /// M  n..2
    pub _0070: String,
    /// First and last transfer
    ///
    /// C  a1
    pub _0073: Option<String>,
}

/// SEL - SEAL NUMBER
///
/// To specify a seal number related to equipment.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Sel {
    /// SEAL NUMBER
    ///
    /// M  an..10
    pub _010: String,
    /// SEAL ISSUER
    pub _020: Option<C215>,
    /// SEAL CONDITION, CODED
    ///
    /// C  an..3
    pub _030: Option<String>,
}

/// TDT - DETAILS OF TRANSPORT
///
/// To specify the transport details such as mode of
/// transport, means of transport, its conveyance
/// reference number and the identification of the means
/// of transport.
/// The segment may be pointed to by the TPL segment.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Tdt {
    pub _010: String,
    pub _020: String,
    pub _030: C220,
    pub _040: C228,
    pub _050: C040,
    pub _060: String,
    pub _070: C401,
    pub _080: C222,
    pub _090: String,
}

/// TMD - TRANSPORT MOVEMENT DETAILS
///
/// To specify transport movement details for a goods item
/// or equipment.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Tmd {
    /// MOVEMENT TYPE
    pub _010: Option<C219>,
    /// EQUIPMENT PLAN
    ///
    /// C  an..26
    pub _020: Option<String>,
    /// HAULAGE ARRANGEMENTS, CODED
    ///
    /// C  an..3
    pub _030: Option<String>,
}

/// TMP - TEMPERATURE
///
/// To specify the temperature setting.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Tmp {
    /// TEMPERATURE QUALIFIER
    ///
    /// M  an..3
    pub _010: String,
    /// TEMPERATURE SETTING
    pub _020: Option<C239>,
}

/// UNH - MESSAGE HEADER
///
/// To head, identify and specify a message.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Unh {
    /// MESSAGE REFERENCE NUMBER
    ///
    /// M  an..14
    pub _010: String,
    /// MESSAGE IDENTIFIER
    pub _020: Option<S009>,
    /// COMMON ACCESS REFERENCE
    ///
    /// C  an..35
    pub _030: Option<String>,
    /// STATUS OF THE TRANSFER
    pub _040: Option<S010>,
}

/// UNT - MESSAGE TRAILER
///
/// To end and check the completeness of a message.
#[derive(Debug, Serialize, Deserialize, Default, Clone, DisplayOuterSegment)]
pub struct Unt {
    /// NUMBER OF SEGMENTS IN THE MESSAGE
    ///
    /// M  n..6
    pub _010: String,
    /// MESSAGE REFERENCE NUMBER
    ///
    /// M  an..14
    pub _020: String,
}