x12_alt 0.1.0

Data types for X12 EDI
Documentation
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
use std::fmt;
use serde::{de, Deserialize, ser, Serialize};
/**1250

See docs at <https://www.stedi.com/edi/x12-005010/element/1250>*/
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum DateTimePeriodFormatQualifier {
    ///CC - First Two Digits of Year Expressed in Format CCYY
    FirstTwoDigitsOfYearExpressedInFormatCcyy,
    ///CD - Month and Year Expressed in Format MMMYYYY
    MonthAndYearExpressedInFormatMmmyyyy,
    ///CM - Date in Format CCYYMM
    DateInFormatCcyymm,
    ///CQ - Date in Format CCYYQ
    DateInFormatCcyyq,
    ///CY - Year Expressed in Format CCYY
    YearExpressedInFormatCcyy,
    ///D6 - Date Expressed in Format YYMMDD
    DateExpressedInFormatYymmdd,
    ///D8 - Date Expressed in Format CCYYMMDD
    DateExpressedInFormatCcyymmdd,
    ///DA - Range of Dates within a Single Month Expressed in Format DD-DD
    RangeOfDatesWithinASingleMonthExpressedInFormatDdDd,
    ///DB - Date Expressed in Format MMDDCCYY
    DateExpressedInFormatMmddccyy,
    ///DD - Day of Month in Numeric Format
    DayOfMonthInNumericFormat,
    ///DDT - Range of Dates and Time, Expressed in CCYYMMDD-CCYYMMDDHHMM
    CodeDDT,
    ///DT - Date and Time Expressed in Format CCYYMMDDHHMM
    DateAndTimeExpressedInFormatCcyymmddhhmm,
    ///DTD - Range of Dates and Time, Expressed in CCYYMMDDHHMM-CCYYMMDD
    CodeDTD,
    ///DTS - Range of Date and Time Expressed in Format CCYYMMDDHHMMSS-CCYYMMDDHHMMSS
    RangeOfDateAndTimeExpressedInFormatCcyymmddhhmmssCcyymmddhhmmss,
    ///EH - Last Digit of Year and Julian Date Expressed in Format YDDD
    LastDigitOfYearAndJulianDateExpressedInFormatYddd,
    ///KA - Date Expressed in Format YYMMMDD
    DateExpressedInFormatYymmmdd,
    ///MCY - MMCCYY
    Mmccyy,
    ///MD - Month of Year and Day of Month Expressed in Format MMDD
    MonthOfYearAndDayOfMonthExpressedInFormatMmdd,
    ///MM - Month of Year in Numeric Format
    MonthOfYearInNumericFormat,
    ///RD - Range of Dates Expressed in Format MMDDCCYY-MMDDCCYY
    RangeOfDatesExpressedInFormatMmddccyyMmddccyy,
    ///RD2 - Range of Years Expressed in Format YY-YY
    RangeOfYearsExpressedInFormatYyYy,
    ///RD4 - Range of Years Expressed in Format CCYY-CCYY
    RangeOfYearsExpressedInFormatCcyyCcyy,
    ///RD5 - Range of Years and Months Expressed in Format CCYYMM-CCYYMM
    RangeOfYearsAndMonthsExpressedInFormatCcyymmCcyymm,
    ///RD6 - Range of Dates Expressed in Format YYMMDD-YYMMDD
    RangeOfDatesExpressedInFormatYymmddYymmdd,
    ///RD8 - Range of Dates Expressed in Format CCYYMMDD-CCYYMMDD
    RangeOfDatesExpressedInFormatCcyymmddCcyymmdd,
    ///RDM - Range of Dates Expressed in Format YYMMDD-MMDD
    RangeOfDatesExpressedInFormatYymmddMmdd,
    ///RDT - Range of Date and Time, Expressed in Format CCYYMMDDHHMM-CCYYMMDDHHMM
    CodeRDT,
    ///RMD - Range of Months and Days Expressed in Format MMDD-MMDD
    RangeOfMonthsAndDaysExpressedInFormatMmddMmdd,
    ///RMY - Range of Years and Months Expressed in Format YYMM-YYMM
    RangeOfYearsAndMonthsExpressedInFormatYymmYymm,
    ///RTM - Range of Time Expressed in Format HHMM-HHMM
    RangeOfTimeExpressedInFormatHhmmHhmm,
    ///RTS - Date and Time Expressed in Format CCYYMMDDHHMMSS
    DateAndTimeExpressedInFormatCcyymmddhhmmss,
    ///TC - Julian Date Expressed in Format DDD
    JulianDateExpressedInFormatDdd,
    ///TM - Time Expressed in Format HHMM
    TimeExpressedInFormatHhmm,
    ///TQ - Date Expressed in Format MMYY
    DateExpressedInFormatMmyy,
    ///TR - Date and Time Expressed in Format DDMMYYHHMM
    DateAndTimeExpressedInFormatDdmmyyhhmm,
    ///TS - Time Expressed in Format HHMMSS
    TimeExpressedInFormatHhmmss,
    ///TT - Date Expressed in Format MMDDYY
    DateExpressedInFormatMmddyy,
    ///TU - Date Expressed in Format YYDDD
    DateExpressedInFormatYyddd,
    ///UN - Unstructured
    Unstructured,
    ///YM - Year and Month Expressed in Format YYMM
    YearAndMonthExpressedInFormatYymm,
    ///YMM - Range of Year and Months, Expressed in CCYYMMM-MMM Format
    CodeYMM,
    ///YY - Last Two Digits of Year Expressed in Format CCYY
    LastTwoDigitsOfYearExpressedInFormatCcyy,
}
impl DateTimePeriodFormatQualifier {
    pub fn code(&self) -> &str {
        {
            use DateTimePeriodFormatQualifier::*;
            match self {
                FirstTwoDigitsOfYearExpressedInFormatCcyy => "CC",
                MonthAndYearExpressedInFormatMmmyyyy => "CD",
                DateInFormatCcyymm => "CM",
                DateInFormatCcyyq => "CQ",
                YearExpressedInFormatCcyy => "CY",
                DateExpressedInFormatYymmdd => "D6",
                DateExpressedInFormatCcyymmdd => "D8",
                RangeOfDatesWithinASingleMonthExpressedInFormatDdDd => "DA",
                DateExpressedInFormatMmddccyy => "DB",
                DayOfMonthInNumericFormat => "DD",
                CodeDDT => "DDT",
                DateAndTimeExpressedInFormatCcyymmddhhmm => "DT",
                CodeDTD => "DTD",
                RangeOfDateAndTimeExpressedInFormatCcyymmddhhmmssCcyymmddhhmmss => "DTS",
                LastDigitOfYearAndJulianDateExpressedInFormatYddd => "EH",
                DateExpressedInFormatYymmmdd => "KA",
                Mmccyy => "MCY",
                MonthOfYearAndDayOfMonthExpressedInFormatMmdd => "MD",
                MonthOfYearInNumericFormat => "MM",
                RangeOfDatesExpressedInFormatMmddccyyMmddccyy => "RD",
                RangeOfYearsExpressedInFormatYyYy => "RD2",
                RangeOfYearsExpressedInFormatCcyyCcyy => "RD4",
                RangeOfYearsAndMonthsExpressedInFormatCcyymmCcyymm => "RD5",
                RangeOfDatesExpressedInFormatYymmddYymmdd => "RD6",
                RangeOfDatesExpressedInFormatCcyymmddCcyymmdd => "RD8",
                RangeOfDatesExpressedInFormatYymmddMmdd => "RDM",
                CodeRDT => "RDT",
                RangeOfMonthsAndDaysExpressedInFormatMmddMmdd => "RMD",
                RangeOfYearsAndMonthsExpressedInFormatYymmYymm => "RMY",
                RangeOfTimeExpressedInFormatHhmmHhmm => "RTM",
                DateAndTimeExpressedInFormatCcyymmddhhmmss => "RTS",
                JulianDateExpressedInFormatDdd => "TC",
                TimeExpressedInFormatHhmm => "TM",
                DateExpressedInFormatMmyy => "TQ",
                DateAndTimeExpressedInFormatDdmmyyhhmm => "TR",
                TimeExpressedInFormatHhmmss => "TS",
                DateExpressedInFormatMmddyy => "TT",
                DateExpressedInFormatYyddd => "TU",
                Unstructured => "UN",
                YearAndMonthExpressedInFormatYymm => "YM",
                CodeYMM => "YMM",
                LastTwoDigitsOfYearExpressedInFormatCcyy => "YY",
            }
        }
    }
    pub fn from_code(code: &[u8]) -> Option<DateTimePeriodFormatQualifier> {
        use DateTimePeriodFormatQualifier::*;
        match code {
            b"CC" => Some(FirstTwoDigitsOfYearExpressedInFormatCcyy),
            b"CD" => Some(MonthAndYearExpressedInFormatMmmyyyy),
            b"CM" => Some(DateInFormatCcyymm),
            b"CQ" => Some(DateInFormatCcyyq),
            b"CY" => Some(YearExpressedInFormatCcyy),
            b"D6" => Some(DateExpressedInFormatYymmdd),
            b"D8" => Some(DateExpressedInFormatCcyymmdd),
            b"DA" => Some(RangeOfDatesWithinASingleMonthExpressedInFormatDdDd),
            b"DB" => Some(DateExpressedInFormatMmddccyy),
            b"DD" => Some(DayOfMonthInNumericFormat),
            b"DDT" => Some(CodeDDT),
            b"DT" => Some(DateAndTimeExpressedInFormatCcyymmddhhmm),
            b"DTD" => Some(CodeDTD),
            b"DTS" => {
                Some(RangeOfDateAndTimeExpressedInFormatCcyymmddhhmmssCcyymmddhhmmss)
            }
            b"EH" => Some(LastDigitOfYearAndJulianDateExpressedInFormatYddd),
            b"KA" => Some(DateExpressedInFormatYymmmdd),
            b"MCY" => Some(Mmccyy),
            b"MD" => Some(MonthOfYearAndDayOfMonthExpressedInFormatMmdd),
            b"MM" => Some(MonthOfYearInNumericFormat),
            b"RD" => Some(RangeOfDatesExpressedInFormatMmddccyyMmddccyy),
            b"RD2" => Some(RangeOfYearsExpressedInFormatYyYy),
            b"RD4" => Some(RangeOfYearsExpressedInFormatCcyyCcyy),
            b"RD5" => Some(RangeOfYearsAndMonthsExpressedInFormatCcyymmCcyymm),
            b"RD6" => Some(RangeOfDatesExpressedInFormatYymmddYymmdd),
            b"RD8" => Some(RangeOfDatesExpressedInFormatCcyymmddCcyymmdd),
            b"RDM" => Some(RangeOfDatesExpressedInFormatYymmddMmdd),
            b"RDT" => Some(CodeRDT),
            b"RMD" => Some(RangeOfMonthsAndDaysExpressedInFormatMmddMmdd),
            b"RMY" => Some(RangeOfYearsAndMonthsExpressedInFormatYymmYymm),
            b"RTM" => Some(RangeOfTimeExpressedInFormatHhmmHhmm),
            b"RTS" => Some(DateAndTimeExpressedInFormatCcyymmddhhmmss),
            b"TC" => Some(JulianDateExpressedInFormatDdd),
            b"TM" => Some(TimeExpressedInFormatHhmm),
            b"TQ" => Some(DateExpressedInFormatMmyy),
            b"TR" => Some(DateAndTimeExpressedInFormatDdmmyyhhmm),
            b"TS" => Some(TimeExpressedInFormatHhmmss),
            b"TT" => Some(DateExpressedInFormatMmddyy),
            b"TU" => Some(DateExpressedInFormatYyddd),
            b"UN" => Some(Unstructured),
            b"YM" => Some(YearAndMonthExpressedInFormatYymm),
            b"YMM" => Some(CodeYMM),
            b"YY" => Some(LastTwoDigitsOfYearExpressedInFormatCcyy),
            _ => None,
        }
    }
    fn description(&self) -> &str {
        use DateTimePeriodFormatQualifier::*;
        match self {
            FirstTwoDigitsOfYearExpressedInFormatCcyy => {
                "First Two Digits of Year Expressed in Format CCYY"
            }
            MonthAndYearExpressedInFormatMmmyyyy => {
                "Month and Year Expressed in Format MMMYYYY"
            }
            DateInFormatCcyymm => "Date in Format CCYYMM",
            DateInFormatCcyyq => "Date in Format CCYYQ",
            YearExpressedInFormatCcyy => "Year Expressed in Format CCYY",
            DateExpressedInFormatYymmdd => "Date Expressed in Format YYMMDD",
            DateExpressedInFormatCcyymmdd => "Date Expressed in Format CCYYMMDD",
            RangeOfDatesWithinASingleMonthExpressedInFormatDdDd => {
                "Range of Dates within a Single Month Expressed in Format DD-DD"
            }
            DateExpressedInFormatMmddccyy => "Date Expressed in Format MMDDCCYY",
            DayOfMonthInNumericFormat => "Day of Month in Numeric Format",
            CodeDDT => "Range of Dates and Time, Expressed in CCYYMMDD-CCYYMMDDHHMM",
            DateAndTimeExpressedInFormatCcyymmddhhmm => {
                "Date and Time Expressed in Format CCYYMMDDHHMM"
            }
            CodeDTD => "Range of Dates and Time, Expressed in CCYYMMDDHHMM-CCYYMMDD",
            RangeOfDateAndTimeExpressedInFormatCcyymmddhhmmssCcyymmddhhmmss => {
                "Range of Date and Time Expressed in Format CCYYMMDDHHMMSS-CCYYMMDDHHMMSS"
            }
            LastDigitOfYearAndJulianDateExpressedInFormatYddd => {
                "Last Digit of Year and Julian Date Expressed in Format YDDD"
            }
            DateExpressedInFormatYymmmdd => "Date Expressed in Format YYMMMDD",
            Mmccyy => "MMCCYY",
            MonthOfYearAndDayOfMonthExpressedInFormatMmdd => {
                "Month of Year and Day of Month Expressed in Format MMDD"
            }
            MonthOfYearInNumericFormat => "Month of Year in Numeric Format",
            RangeOfDatesExpressedInFormatMmddccyyMmddccyy => {
                "Range of Dates Expressed in Format MMDDCCYY-MMDDCCYY"
            }
            RangeOfYearsExpressedInFormatYyYy => {
                "Range of Years Expressed in Format YY-YY"
            }
            RangeOfYearsExpressedInFormatCcyyCcyy => {
                "Range of Years Expressed in Format CCYY-CCYY"
            }
            RangeOfYearsAndMonthsExpressedInFormatCcyymmCcyymm => {
                "Range of Years and Months Expressed in Format CCYYMM-CCYYMM"
            }
            RangeOfDatesExpressedInFormatYymmddYymmdd => {
                "Range of Dates Expressed in Format YYMMDD-YYMMDD"
            }
            RangeOfDatesExpressedInFormatCcyymmddCcyymmdd => {
                "Range of Dates Expressed in Format CCYYMMDD-CCYYMMDD"
            }
            RangeOfDatesExpressedInFormatYymmddMmdd => {
                "Range of Dates Expressed in Format YYMMDD-MMDD"
            }
            CodeRDT => {
                "Range of Date and Time, Expressed in Format CCYYMMDDHHMM-CCYYMMDDHHMM"
            }
            RangeOfMonthsAndDaysExpressedInFormatMmddMmdd => {
                "Range of Months and Days Expressed in Format MMDD-MMDD"
            }
            RangeOfYearsAndMonthsExpressedInFormatYymmYymm => {
                "Range of Years and Months Expressed in Format YYMM-YYMM"
            }
            RangeOfTimeExpressedInFormatHhmmHhmm => {
                "Range of Time Expressed in Format HHMM-HHMM"
            }
            DateAndTimeExpressedInFormatCcyymmddhhmmss => {
                "Date and Time Expressed in Format CCYYMMDDHHMMSS"
            }
            JulianDateExpressedInFormatDdd => "Julian Date Expressed in Format DDD",
            TimeExpressedInFormatHhmm => "Time Expressed in Format HHMM",
            DateExpressedInFormatMmyy => "Date Expressed in Format MMYY",
            DateAndTimeExpressedInFormatDdmmyyhhmm => {
                "Date and Time Expressed in Format DDMMYYHHMM"
            }
            TimeExpressedInFormatHhmmss => "Time Expressed in Format HHMMSS",
            DateExpressedInFormatMmddyy => "Date Expressed in Format MMDDYY",
            DateExpressedInFormatYyddd => "Date Expressed in Format YYDDD",
            Unstructured => "Unstructured",
            YearAndMonthExpressedInFormatYymm => {
                "Year and Month Expressed in Format YYMM"
            }
            CodeYMM => "Range of Year and Months, Expressed in CCYYMMM-MMM Format",
            LastTwoDigitsOfYearExpressedInFormatCcyy => {
                "Last Two Digits of Year Expressed in Format CCYY"
            }
        }
    }
    fn from_description(description: &str) -> Option<DateTimePeriodFormatQualifier> {
        {
            use DateTimePeriodFormatQualifier::*;
            match description {
                "First Two Digits of Year Expressed in Format CCYY" => {
                    Some(FirstTwoDigitsOfYearExpressedInFormatCcyy)
                }
                "Month and Year Expressed in Format MMMYYYY" => {
                    Some(MonthAndYearExpressedInFormatMmmyyyy)
                }
                "Date in Format CCYYMM" => Some(DateInFormatCcyymm),
                "Date in Format CCYYQ" => Some(DateInFormatCcyyq),
                "Year Expressed in Format CCYY" => Some(YearExpressedInFormatCcyy),
                "Date Expressed in Format YYMMDD" => Some(DateExpressedInFormatYymmdd),
                "Date Expressed in Format CCYYMMDD" => {
                    Some(DateExpressedInFormatCcyymmdd)
                }
                "Range of Dates within a Single Month Expressed in Format DD-DD" => {
                    Some(RangeOfDatesWithinASingleMonthExpressedInFormatDdDd)
                }
                "Date Expressed in Format MMDDCCYY" => {
                    Some(DateExpressedInFormatMmddccyy)
                }
                "Day of Month in Numeric Format" => Some(DayOfMonthInNumericFormat),
                "Range of Dates and Time, Expressed in CCYYMMDD-CCYYMMDDHHMM" => {
                    Some(CodeDDT)
                }
                "Date and Time Expressed in Format CCYYMMDDHHMM" => {
                    Some(DateAndTimeExpressedInFormatCcyymmddhhmm)
                }
                "Range of Dates and Time, Expressed in CCYYMMDDHHMM-CCYYMMDD" => {
                    Some(CodeDTD)
                }
                "Range of Date and Time Expressed in Format CCYYMMDDHHMMSS-CCYYMMDDHHMMSS" => {
                    Some(RangeOfDateAndTimeExpressedInFormatCcyymmddhhmmssCcyymmddhhmmss)
                }
                "Last Digit of Year and Julian Date Expressed in Format YDDD" => {
                    Some(LastDigitOfYearAndJulianDateExpressedInFormatYddd)
                }
                "Date Expressed in Format YYMMMDD" => Some(DateExpressedInFormatYymmmdd),
                "MMCCYY" => Some(Mmccyy),
                "Month of Year and Day of Month Expressed in Format MMDD" => {
                    Some(MonthOfYearAndDayOfMonthExpressedInFormatMmdd)
                }
                "Month of Year in Numeric Format" => Some(MonthOfYearInNumericFormat),
                "Range of Dates Expressed in Format MMDDCCYY-MMDDCCYY" => {
                    Some(RangeOfDatesExpressedInFormatMmddccyyMmddccyy)
                }
                "Range of Years Expressed in Format YY-YY" => {
                    Some(RangeOfYearsExpressedInFormatYyYy)
                }
                "Range of Years Expressed in Format CCYY-CCYY" => {
                    Some(RangeOfYearsExpressedInFormatCcyyCcyy)
                }
                "Range of Years and Months Expressed in Format CCYYMM-CCYYMM" => {
                    Some(RangeOfYearsAndMonthsExpressedInFormatCcyymmCcyymm)
                }
                "Range of Dates Expressed in Format YYMMDD-YYMMDD" => {
                    Some(RangeOfDatesExpressedInFormatYymmddYymmdd)
                }
                "Range of Dates Expressed in Format CCYYMMDD-CCYYMMDD" => {
                    Some(RangeOfDatesExpressedInFormatCcyymmddCcyymmdd)
                }
                "Range of Dates Expressed in Format YYMMDD-MMDD" => {
                    Some(RangeOfDatesExpressedInFormatYymmddMmdd)
                }
                "Range of Date and Time, Expressed in Format CCYYMMDDHHMM-CCYYMMDDHHMM" => {
                    Some(CodeRDT)
                }
                "Range of Months and Days Expressed in Format MMDD-MMDD" => {
                    Some(RangeOfMonthsAndDaysExpressedInFormatMmddMmdd)
                }
                "Range of Years and Months Expressed in Format YYMM-YYMM" => {
                    Some(RangeOfYearsAndMonthsExpressedInFormatYymmYymm)
                }
                "Range of Time Expressed in Format HHMM-HHMM" => {
                    Some(RangeOfTimeExpressedInFormatHhmmHhmm)
                }
                "Date and Time Expressed in Format CCYYMMDDHHMMSS" => {
                    Some(DateAndTimeExpressedInFormatCcyymmddhhmmss)
                }
                "Julian Date Expressed in Format DDD" => {
                    Some(JulianDateExpressedInFormatDdd)
                }
                "Time Expressed in Format HHMM" => Some(TimeExpressedInFormatHhmm),
                "Date Expressed in Format MMYY" => Some(DateExpressedInFormatMmyy),
                "Date and Time Expressed in Format DDMMYYHHMM" => {
                    Some(DateAndTimeExpressedInFormatDdmmyyhhmm)
                }
                "Time Expressed in Format HHMMSS" => Some(TimeExpressedInFormatHhmmss),
                "Date Expressed in Format MMDDYY" => Some(DateExpressedInFormatMmddyy),
                "Date Expressed in Format YYDDD" => Some(DateExpressedInFormatYyddd),
                "Unstructured" => Some(Unstructured),
                "Year and Month Expressed in Format YYMM" => {
                    Some(YearAndMonthExpressedInFormatYymm)
                }
                "Range of Year and Months, Expressed in CCYYMMM-MMM Format" => {
                    Some(CodeYMM)
                }
                "Last Two Digits of Year Expressed in Format CCYY" => {
                    Some(LastTwoDigitsOfYearExpressedInFormatCcyy)
                }
                _ => None,
            }
        }
    }
}
impl Serialize for DateTimePeriodFormatQualifier {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: ser::Serializer,
    {
        let value = if serializer.is_human_readable() {
            self.description()
        } else {
            self.code()
        };
        serializer.serialize_str(value)
    }
}
struct Visitor;
impl<'de> de::Visitor<'de> for Visitor {
    type Value = DateTimePeriodFormatQualifier;
    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
        formatter.write_str("Date Time Period Format Qualifier")
    }
    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
    where
        E: de::Error,
    {
        DateTimePeriodFormatQualifier::from_description(v)
            .ok_or_else(|| E::custom(
                format!("Invalid Date Time Period Format Qualifier: {}", v),
            ))
    }
    fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
    where
        E: de::Error,
    {
        DateTimePeriodFormatQualifier::from_code(v)
            .ok_or_else(|| E::custom(
                format!(
                    "Invalid Date Time Period Format Qualifier: {}",
                    std::str::from_utf8(v).unwrap()
                ),
            ))
    }
}
impl<'de> Deserialize<'de> for DateTimePeriodFormatQualifier {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: de::Deserializer<'de>,
    {
        if deserializer.is_human_readable() {
            deserializer.deserialize_str(Visitor)
        } else {
            deserializer.deserialize_bytes(Visitor)
        }
    }
}