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
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
extern crate encoding;
extern crate regex;
use self::encoding::{Encoding, DecoderTrap, EncoderTrap};
use self::encoding::all::{ISO_8859_1, UTF_16LE, UTF_16BE, UTF_8};
use errors::*;
use util;
use writable::Writable;
use std::io::{Cursor, Result, Error, ErrorKind};
use std::result;
use std::vec::Vec;
type Readable = ::readable::Readable<Cursor<Vec<u8>>>;
fn trim(text: String) -> String {
let re = regex::Regex::new(r"(^[\x{0}|\x{feff}|\x{fffe}]*|[\x{0}|\x{feff}|\x{fffe}]*$)")
.unwrap();
let text = text.trim();
re.replace_all(text, "").into_owned()
}
pub trait FrameReaderDefault<T> {
fn read(readable: &mut Readable) -> Result<T>;
}
pub trait FrameReaderIdAware<T> {
fn read(readable: &mut Readable, id: &str) -> Result<T>;
}
pub trait FrameReaderVersionAware<T> {
fn read(readable: &mut Readable, version: u8) -> Result<T>;
}
pub trait FrameWriterDefault {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()>;
}
pub trait FrameWriterVersionAware<T> {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>, version: u8) -> Result<()>;
}
pub trait FrameWriterIdAware<T> {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>, id: &str) -> Result<()>;
}
pub trait FlagAware<T> {
fn has_flag(&self, flag: T) -> bool;
fn set_flag(&mut self, flag: T);
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Head {
pub version: u8,
pub minor_version: u8,
pub flag: u8,
pub size: u32,
}
impl Head {
pub fn read(readable: &mut Readable) -> result::Result<Self, ParsingError> {
let tag_id = readable.string(3)?;
let version = readable.u8()?;
let minor_version = readable.u8()?;
let flag = readable.u8()?;
let size = readable.synchsafe()?;
if tag_id != "ID3" {
return Err(ParsingError::BadData(ParsingErrorKind::InvalidV2FrameId));
}
Ok(Head {
version: version,
minor_version: minor_version,
flag: flag,
size: size,
})
}
}
impl FlagAware<HeadFlag> for Head {
fn has_flag(&self, flag: HeadFlag) -> bool {
match self.version {
2 => {
match flag {
HeadFlag::Unsynchronisation => self.flag & util::BIT7 != 0,
HeadFlag::Compression => self.flag & util::BIT6 != 0,
_ => false,
}
}
3 => {
match flag {
HeadFlag::Unsynchronisation => self.flag & util::BIT7 != 0,
HeadFlag::ExtendedHeader => self.flag & util::BIT6 != 0,
HeadFlag::ExperimentalIndicator => self.flag & util::BIT5 != 0,
_ => false,
}
}
4 => {
match flag {
HeadFlag::ExtendedHeader => self.flag & util::BIT6 != 0,
HeadFlag::ExperimentalIndicator => self.flag & util::BIT5 != 0,
HeadFlag::FooterPresent => self.flag & util::BIT4 != 0,
_ => false,
}
}
_ => {
warn!("Header.has_flag=> Unknown version!");
false
}
}
}
fn set_flag(&mut self, flag: HeadFlag) {
match self.version {
2 => {
match flag {
HeadFlag::Unsynchronisation => self.flag = self.flag | util::BIT7,
HeadFlag::Compression => self.flag = self.flag | util::BIT6,
_ => (),
}
}
3 => {
match flag {
HeadFlag::Unsynchronisation => self.flag = self.flag | util::BIT7,
HeadFlag::ExtendedHeader => self.flag = self.flag | util::BIT6,
HeadFlag::ExperimentalIndicator => self.flag = self.flag | util::BIT5,
_ => (),
}
}
4 => {
match flag {
HeadFlag::ExtendedHeader => self.flag = self.flag | util::BIT6,
HeadFlag::ExperimentalIndicator => self.flag = self.flag | util::BIT5,
HeadFlag::FooterPresent => self.flag = self.flag | util::BIT4,
_ => (),
}
}
_ => {
warn!("Header.has_flag=> Unknown version!");
}
}
}
}
impl FrameWriterDefault for Head {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.string("ID3")?;
writable.u8(self.version)?;
writable.u8(self.minor_version)?;
writable.u8(self.flag)?;
writable.synchsafe(self.size)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Frame1 {
pub title: String,
pub artist: String,
pub album: String,
pub year: String,
pub comment: String,
pub track: String,
pub genre: String,
}
impl Frame1 {
pub fn read(readable: &mut Readable) -> result::Result<Self, ParsingError> {
readable.skip(3)?;
let title = util::to_iso8859_1(&readable.bytes(30)?).trim().to_string();
let artist = util::to_iso8859_1(&readable.bytes(30)?).trim().to_string();
let album = util::to_iso8859_1(&readable.bytes(30)?).trim().to_string();
let year = util::to_iso8859_1(&readable.bytes(4)?).trim().to_string();
readable.skip(28)?;
let track_marker = readable.u8()?;
let _track = readable.u8()? & 0xff;
let genre = (readable.u8()? & 0xff).to_string();
readable.skip(-31)?;
let (comment, track) = if track_marker != 0 {
(util::to_iso8859_1(&readable.bytes(30)?).trim().to_string(), String::new())
} else {
(util::to_iso8859_1(&readable.bytes(28)?).trim().to_string(),
if _track == 0 {
String::new()
} else {
_track.to_string()
})
};
Ok(Frame1 {
title: title,
artist: artist,
album: album,
year: year,
comment: comment,
track: track,
genre: genre,
})
}
}
impl FrameWriterDefault for Frame1 {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.string("TAG")?;
writable.write(&util::from_iso8859_1(&self.title, 30))?;
writable.write(&util::from_iso8859_1(&self.artist, 30))?;
writable.write(&util::from_iso8859_1(&self.album, 30))?;
writable.write(&util::from_iso8859_1(&self.year, 4))?;
writable.write(&util::from_iso8859_1(&self.comment, 28))?;
writable.u8(0)?;
match self.track.as_str().parse::<u8>() {
Ok(v) => writable.u8(v)?,
Err(_) => writable.u8(0)?,
};
match self.genre.as_str().parse::<u8>() {
Ok(v) => writable.u8(v)?,
Err(_) => writable.u8(0)?,
};
Ok(())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum FrameHeader {
V22(FrameHeaderV2),
V23(FrameHeaderV3),
V24(FrameHeaderV4),
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FrameHeaderV2 {
pub id: String,
pub size: u32,
}
impl FrameHeaderV2 {
pub fn read(readable: &mut Readable) -> result::Result<Self, ParsingError> {
let id = readable.string(3)?;
let size = readable.u24()?;
Ok(FrameHeaderV2 {
id: id,
size: size,
})
}
}
impl FlagAware<FrameHeaderFlag> for FrameHeaderV2 {
#[allow(unused_variables)]
fn has_flag(&self, flag: FrameHeaderFlag) -> bool {
return false;
}
#[allow(unused_variables)]
fn set_flag(&mut self, flag: FrameHeaderFlag) {}
}
impl FrameWriterDefault for FrameHeaderV2 {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.string(self.id.as_str())?;
writable.u24(self.size)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FrameHeaderV3 {
pub id: String,
pub size: u32,
pub status_flag: u8,
pub encoding_flag: u8,
}
impl FrameHeaderV3 {
pub fn read(readable: &mut Readable) -> result::Result<Self, ParsingError> {
let id = readable.string(4)?;
let size = readable.u32()?;
let status_flag = readable.u8()?;
let encoding_flag = readable.u8()?;
Ok(FrameHeaderV3 {
id: id,
size: size,
status_flag: status_flag,
encoding_flag: encoding_flag,
})
}
}
impl FlagAware<FrameHeaderFlag> for FrameHeaderV3 {
fn has_flag(&self, flag: FrameHeaderFlag) -> bool {
match flag {
FrameHeaderFlag::TagAlter => self.status_flag & util::BIT7 != 0,
FrameHeaderFlag::FileAlter => self.status_flag & util::BIT6 != 0,
FrameHeaderFlag::ReadOnly => self.status_flag & util::BIT5 != 0,
FrameHeaderFlag::Compression => self.encoding_flag & util::BIT7 != 0,
FrameHeaderFlag::Encryption => self.encoding_flag & util::BIT6 != 0,
FrameHeaderFlag::GroupIdentity => self.encoding_flag & util::BIT5 != 0,
_ => false,
}
}
fn set_flag(&mut self, flag: FrameHeaderFlag) {
match flag {
FrameHeaderFlag::TagAlter => self.status_flag = self.status_flag | util::BIT7,
FrameHeaderFlag::FileAlter => self.status_flag = self.status_flag | util::BIT6,
FrameHeaderFlag::ReadOnly => self.status_flag = self.status_flag | util::BIT5,
FrameHeaderFlag::Compression => self.encoding_flag = self.encoding_flag | util::BIT7,
FrameHeaderFlag::Encryption => self.encoding_flag = self.encoding_flag | util::BIT6,
FrameHeaderFlag::GroupIdentity => self.encoding_flag = self.encoding_flag | util::BIT5,
_ => (),
}
}
}
impl FrameWriterDefault for FrameHeaderV3 {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
let mut ext_size = 0;
if self.has_flag(FrameHeaderFlag::GroupIdentity) {
ext_size = 1;
}
if self.has_flag(FrameHeaderFlag::Encryption) {
ext_size = ext_size + 1;
}
if self.has_flag(FrameHeaderFlag::Compression) {
ext_size = ext_size + 4;
}
writable.string(self.id.as_str())?;
writable.u32(self.size + ext_size)?;
writable.u8(self.status_flag)?;
writable.u8(self.encoding_flag)?;
if self.has_flag(FrameHeaderFlag::GroupIdentity) {
writable.u8(0)?;
}
if self.has_flag(FrameHeaderFlag::Encryption) {
writable.u8(0)?;
}
if self.has_flag(FrameHeaderFlag::Compression) {
writable.u32(0)?;
}
Ok(())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FrameHeaderV4 {
pub id: String,
pub size: u32,
pub status_flag: u8,
pub encoding_flag: u8,
}
impl FrameHeaderV4 {
pub fn read(readable: &mut Readable) -> result::Result<Self, ParsingError> {
let id = readable.string(4)?;
let size = readable.synchsafe()?;
let status_flag = readable.u8()?;
let encoding_flag = readable.u8()?;
Ok(FrameHeaderV4 {
id: id,
size: size,
status_flag: status_flag,
encoding_flag: encoding_flag,
})
}
}
impl FlagAware<FrameHeaderFlag> for FrameHeaderV4 {
fn has_flag(&self, flag: FrameHeaderFlag) -> bool {
match flag {
FrameHeaderFlag::TagAlter => self.status_flag & util::BIT6 != 0,
FrameHeaderFlag::FileAlter => self.status_flag & util::BIT5 != 0,
FrameHeaderFlag::ReadOnly => self.status_flag & util::BIT4 != 0,
FrameHeaderFlag::GroupIdentity => self.encoding_flag & util::BIT6 != 0,
FrameHeaderFlag::Compression => self.encoding_flag & util::BIT3 != 0,
FrameHeaderFlag::Encryption => self.encoding_flag & util::BIT2 != 0,
FrameHeaderFlag::Unsynchronisation => self.encoding_flag & util::BIT1 != 0,
FrameHeaderFlag::DataLength => self.encoding_flag & util::BIT0 != 0,
}
}
fn set_flag(&mut self, flag: FrameHeaderFlag) {
match flag {
FrameHeaderFlag::TagAlter => self.status_flag = self.status_flag | util::BIT6,
FrameHeaderFlag::FileAlter => self.status_flag = self.status_flag | util::BIT5,
FrameHeaderFlag::ReadOnly => self.status_flag = self.status_flag | util::BIT4,
FrameHeaderFlag::GroupIdentity => self.encoding_flag = self.encoding_flag | util::BIT6,
FrameHeaderFlag::Compression => self.encoding_flag = self.encoding_flag | util::BIT3,
FrameHeaderFlag::Encryption => self.encoding_flag = self.encoding_flag | util::BIT2,
FrameHeaderFlag::Unsynchronisation => {
self.encoding_flag = self.encoding_flag | util::BIT1
}
FrameHeaderFlag::DataLength => self.encoding_flag = self.encoding_flag | util::BIT0,
}
}
}
impl FrameWriterDefault for FrameHeaderV4 {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
let mut ext_size = 0;
if self.has_flag(FrameHeaderFlag::GroupIdentity) {
ext_size = 1;
}
if self.has_flag(FrameHeaderFlag::Encryption) {
ext_size = ext_size + 1;
}
if self.has_flag(FrameHeaderFlag::DataLength) {
ext_size = ext_size + 4;
}
writable.string(self.id.as_str())?;
writable.synchsafe(self.size + ext_size)?;
writable.u8(self.status_flag)?;
writable.u8(self.encoding_flag)?;
if self.has_flag(FrameHeaderFlag::GroupIdentity) {
writable.u8(0)?;
}
if self.has_flag(FrameHeaderFlag::Encryption) {
writable.u8(0)?;
}
if self.has_flag(FrameHeaderFlag::DataLength) {
writable.u32(0)?;
}
Ok(())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum TextEncoding {
ISO88591,
UTF16LE,
UTF16BE,
UTF8,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum PictureType {
Other,
FileIcon,
OtherFileIcon,
CoverFront,
CoverBack,
LeafletPage,
Media,
LeadArtist,
Artist,
Conductor,
Band,
Composer,
Lyricist,
RecordingLocation,
DuringRecording,
DuringPerformance,
MovieScreenCapture,
BrightColouredFish,
Illustration,
BandLogotype,
PublisherLogoType,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum ReceivedAs {
Other,
StandardCDAlbum,
CompressedAudioOnCD,
FileOverInternet,
StreamOverInternet,
AsNoteSheets,
AsNoteSheetsInBook,
MusicOnMedia,
NonMusicalMerchandise,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum InterpolationMethod {
Band,
Linear,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum ContentType {
Other,
Lyrics,
TextTranscription,
MovementName,
Events,
Chord,
Trivia,
UrlsToWebpages,
UrlsToImages,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum TimestampFormat {
MpecFrames,
Milliseconds,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum EventTimingCode {
Padding(u32),
EndOfInitialSilence(u32),
IntroStart(u32),
MainPartStart(u32),
OutroStart(u32),
OutroEnd(u32),
VerseStart(u32),
RefrainStart(u32),
InterludeStart(u32),
ThemeStart(u32),
VariationStart(u32),
KeyChange(u32),
TimeChange(u32),
MomentaryUnwantedNoise(u32),
SustainedNoise(u32),
SustainedNoiseEnd(u32),
IntroEnd(u32),
MainPartEnd(u32),
VerseEnd(u32),
RefrainEnd(u32),
ThemeEnd(u32),
Profanity(u32),
ProfanityEnd(u32),
ReservedForFutureUse(u32, u8),
NotPredefinedSynch(u32, u8),
AudioEnd(u32),
AudioFileEnds(u32),
OneMoreByteOfEventsFollows(u32),
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum FrameHeaderFlag {
TagAlter,
FileAlter,
ReadOnly,
Compression,
Encryption,
GroupIdentity,
Unsynchronisation,
DataLength,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum HeadFlag {
Unsynchronisation,
Compression,
ExtendedHeader,
ExperimentalIndicator,
FooterPresent,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct BUF {
pub buffer_size: u32,
pub embedded_info_flag: u8,
pub offset_to_next_tag: u32,
}
impl FrameReaderDefault<BUF> for BUF {
fn read(readable: &mut Readable) -> Result<BUF> {
let buffer_size = readable.u24()?;
let embedded_info_flag = readable.u8()?;
let offset_to_next_tag = readable.u32()?;
Ok(BUF {
buffer_size: buffer_size,
embedded_info_flag: embedded_info_flag,
offset_to_next_tag: offset_to_next_tag,
})
}
}
impl FrameWriterDefault for BUF {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u24(self.buffer_size)?;
writable.u8(self.embedded_info_flag)?;
writable.u32(self.offset_to_next_tag)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CRM {
pub owner_identifier: String,
pub content: String,
pub encrypted_datablock: Vec<u8>,
}
impl FrameReaderDefault<CRM> for CRM {
fn read(readable: &mut Readable) -> Result<CRM> {
let owner_identifier = readable.non_utf16_string()?;
let content = readable.non_utf16_string()?;
let encrypted_datablock = readable.all_bytes()?;
Ok(CRM {
owner_identifier: owner_identifier,
content: content,
encrypted_datablock: encrypted_datablock,
})
}
}
impl FrameWriterDefault for CRM {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.non_utf16_string(self.owner_identifier.as_str())?;
writable.non_utf16_string(self.content.as_str())?;
writable.write(&self.encrypted_datablock)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct PIC {
pub text_encoding: TextEncoding,
pub image_format: String,
pub picture_type: PictureType,
pub description: String,
pub picture_data: Vec<u8>,
}
impl FrameReaderDefault<PIC> for PIC {
fn read(readable: &mut Readable) -> Result<PIC> {
let text_encoding = util::to_encoding(readable.u8()?);
let image_format = readable.string(3)?;
let picture_type = util::to_picture_type(readable.u8()?);
let description = util::read_null_terminated(&text_encoding, readable)?;
let picture_data = readable.all_bytes()?;
Ok(PIC {
text_encoding: text_encoding,
image_format: image_format,
picture_type: picture_type,
description: description,
picture_data: picture_data,
})
}
}
impl FrameWriterDefault for PIC {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
writable.string(&self.image_format[0..3])?;
writable.u8(util::from_picture_type(&self.picture_type))?;
util::write_null_terminated(&self.text_encoding, self.description.as_str(), writable)?;
writable.write(&self.picture_data)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct AENC {
pub owner_identifier: String,
pub preview_start: u16,
pub preview_end: u16,
pub encryption_info: Vec<u8>,
}
impl FrameReaderDefault<AENC> for AENC {
fn read(readable: &mut Readable) -> Result<AENC> {
let owner_identifier = readable.non_utf16_string()?;
let preview_start = readable.u16()?;
let preview_end = readable.u16()?;
let encryption_info = readable.all_bytes()?;
Ok(AENC {
owner_identifier: owner_identifier,
preview_start: preview_start,
preview_end: preview_end,
encryption_info: encryption_info,
})
}
}
impl FrameWriterDefault for AENC {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.non_utf16_string(self.owner_identifier.as_str())?;
writable.u16(self.preview_start)?;
writable.u16(self.preview_end)?;
writable.write(&self.encryption_info)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct APIC {
pub text_encoding: TextEncoding,
pub mime_type: String,
pub picture_type: PictureType,
pub description: String,
pub picture_data: Vec<u8>,
}
impl FrameReaderDefault<APIC> for APIC {
fn read(readable: &mut Readable) -> Result<APIC> {
let text_encoding = util::to_encoding(readable.u8()?);
let mine_type = readable.non_utf16_string()?;
let picture_type = util::to_picture_type(readable.u8()?);
let description = util::read_null_terminated(&text_encoding, readable)?;
let picture_data = readable.all_bytes()?;
Ok(APIC {
text_encoding: text_encoding,
mime_type: mine_type,
picture_type: picture_type,
description: description,
picture_data: picture_data,
})
}
}
impl FrameWriterDefault for APIC {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
writable.non_utf16_string(self.mime_type.as_str())?;
writable.u8(util::from_picture_type(&self.picture_type))?;
util::write_null_terminated(&self.text_encoding, self.description.as_str(), writable)?;
writable.write(&self.picture_data)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ASPI {
pub indexed_data_start: u32,
pub indexed_data_length: u32,
pub number_of_index_points: u16,
pub bit_per_index_point: u8,
pub fraction_at_index: u8,
}
impl FrameReaderDefault<ASPI> for ASPI {
fn read(readable: &mut Readable) -> Result<ASPI> {
let indexed_data_start = readable.u32()?;
let indexed_data_length = readable.u32()?;
let number_of_index_points = readable.u16()?;
let bit_per_index_point = readable.u8()?;
let fraction_at_index = readable.u8()?;
Ok(ASPI {
indexed_data_start: indexed_data_start,
indexed_data_length: indexed_data_length,
number_of_index_points: number_of_index_points,
bit_per_index_point: bit_per_index_point,
fraction_at_index: fraction_at_index,
})
}
}
impl FrameWriterDefault for ASPI {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u32(self.indexed_data_start)?;
writable.u32(self.indexed_data_length)?;
writable.u16(self.number_of_index_points)?;
writable.u8(self.bit_per_index_point)?;
writable.u8(self.fraction_at_index)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct COMM {
pub text_encoding: TextEncoding,
pub language: String,
pub short_description: String,
pub actual_text: String,
}
impl FrameReaderDefault<COMM> for COMM {
fn read(readable: &mut Readable) -> Result<COMM> {
let text_encoding = util::to_encoding(readable.u8()?);
let language = readable.string(3)?;
let short_description = util::read_null_terminated(&text_encoding, readable)?;
let actual_text = self::trim(readable.all_string()?);
Ok(COMM {
text_encoding: text_encoding,
language: language,
short_description: short_description,
actual_text: actual_text,
})
}
}
impl FrameWriterDefault for COMM {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
writable.string(&self.language[0..3])?;
util::write_null_terminated(&self.text_encoding,
self.short_description.as_str(),
writable)?;
writable.string(self.actual_text.as_str())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct COMR {
pub text_encoding: TextEncoding,
pub price_string: String,
pub valid_until: String,
pub contact_url: String,
pub received_as: ReceivedAs,
pub name_of_seller: String,
pub description: String,
pub picture_mime_type: String,
pub seller_logo: Vec<u8>,
}
impl FrameReaderDefault<COMR> for COMR {
fn read(readable: &mut Readable) -> Result<COMR> {
let text_encoding = util::to_encoding(readable.u8()?);
let price_string = readable.non_utf16_string()?;
let valid_until = readable.string(8)?;
let contact_url = readable.non_utf16_string()?;
let received_as = util::to_received_as(readable.u8()?);
let name_of_seller = readable.utf16_string()?;
let description = readable.utf16_string()?;
let picture_mime_type = readable.non_utf16_string()?;
let seller_logo = readable.all_bytes()?;
Ok(COMR {
text_encoding: text_encoding,
price_string: price_string,
valid_until: valid_until,
contact_url: contact_url,
received_as: received_as,
name_of_seller: name_of_seller,
description: description,
picture_mime_type: picture_mime_type,
seller_logo: seller_logo,
})
}
}
impl FrameWriterDefault for COMR {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
writable.string(self.price_string.as_str())?;
writable.string(&self.valid_until[0..8])?;
writable.non_utf16_string(self.contact_url.as_str())?;
writable.u8(util::from_received_as(&self.received_as))?;
writable.utf16_string(self.name_of_seller.as_str())?;
writable.string(self.description.as_str())?;
writable.non_utf16_string(self.picture_mime_type.as_str())?;
writable.write(&self.seller_logo)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ENCR {
pub owner_identifier: String,
pub method_symbol: u8,
pub encryption_data: Vec<u8>,
}
impl FrameReaderDefault<ENCR> for ENCR {
fn read(readable: &mut Readable) -> Result<ENCR> {
let owner_identifier = readable.non_utf16_string()?;
let method_symbol = readable.u8()?;
let encryption_data = readable.all_bytes()?;
Ok(ENCR {
owner_identifier: owner_identifier,
method_symbol: method_symbol,
encryption_data: encryption_data,
})
}
}
impl FrameWriterDefault for ENCR {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.string(self.owner_identifier.as_str())?;
writable.u8(self.method_symbol)?;
writable.write(&self.encryption_data)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EQUA {
pub data: Vec<u8>,
}
impl FrameReaderDefault<EQUA> for EQUA {
fn read(readable: &mut Readable) -> Result<EQUA> {
let data = readable.all_bytes()?;
Ok(EQUA { data: data })
}
}
impl FrameWriterDefault for EQUA {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.write(&self.data)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct EQU2 {
pub interpolation_method: InterpolationMethod,
pub identification: String,
}
impl FrameReaderDefault<EQU2> for EQU2 {
fn read(readable: &mut Readable) -> Result<EQU2> {
let interpolation_method = util::to_interpolation_method(readable.u8()?);
let identification = readable.non_utf16_string()?;
Ok(EQU2 {
interpolation_method: interpolation_method,
identification: identification,
})
}
}
impl FrameWriterDefault for EQU2 {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_interpolation_method(&self.interpolation_method))?;
writable.string(self.identification.as_str())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ETCO {
pub timestamp_format: TimestampFormat,
pub event_timing_codes: Vec<EventTimingCode>,
}
impl FrameReaderDefault<ETCO> for ETCO {
fn read(readable: &mut Readable) -> Result<ETCO> {
let timestamp_format = util::to_timestamp_format(readable.u8()?);
let mut event_timing_codes: Vec<EventTimingCode> = Vec::new();
loop {
let mut is_break = true;
if let Ok(code_type) = readable.u8() {
if let Ok(timestamp) = readable.u32() {
let event_timing_code = util::to_event_timing_code(code_type, timestamp);
event_timing_codes.push(event_timing_code);
is_break = false;
}
}
if is_break {
break;
}
}
Ok(ETCO {
timestamp_format: timestamp_format,
event_timing_codes: event_timing_codes,
})
}
}
impl FrameWriterDefault for ETCO {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_timestamp_format(&self.timestamp_format))?;
for e in &self.event_timing_codes {
let (code, timestamp) = util::from_event_timing_code(&e);
writable.u8(code)?;
writable.u32(timestamp)?;
}
Ok((()))
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct GEOB {
pub text_encoding: TextEncoding,
pub mime_type: String,
pub filename: String,
pub content_description: String,
pub encapsulation_object: Vec<u8>,
}
impl FrameReaderDefault<GEOB> for GEOB {
fn read(readable: &mut Readable) -> Result<GEOB> {
let text_encoding = util::to_encoding(readable.u8()?);
let mime_type = readable.non_utf16_string()?;
let filename = util::read_null_terminated(&text_encoding, readable)?;
let content_description = util::read_null_terminated(&text_encoding, readable)?;
let encapsulation_object = readable.all_bytes()?;
Ok(GEOB {
text_encoding: text_encoding,
mime_type: mime_type,
filename: filename,
content_description: content_description,
encapsulation_object: encapsulation_object,
})
}
}
impl FrameWriterDefault for GEOB {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
writable.non_utf16_string(self.mime_type.as_str())?;
util::write_null_terminated(&self.text_encoding, self.filename.as_str(), writable)?;
util::write_null_terminated(&self.text_encoding,
self.content_description.as_str(),
writable)?;
writable.write(&self.encapsulation_object)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct GRID {
pub owner_identifier: String,
pub group_symbol: u8,
pub group_dependent_data: Vec<u8>,
}
impl FrameReaderDefault<GRID> for GRID {
fn read(readable: &mut Readable) -> Result<GRID> {
let owner_identifier = readable.non_utf16_string()?;
let group_symbol = readable.u8()?;
let group_dependent_data = readable.all_bytes()?;
Ok(GRID {
owner_identifier: owner_identifier,
group_symbol: group_symbol,
group_dependent_data: group_dependent_data,
})
}
}
impl FrameWriterDefault for GRID {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.non_utf16_string(self.owner_identifier.as_str())?;
writable.u8(self.group_symbol)?;
writable.write(&self.group_dependent_data)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct IPLS {
pub text_encoding: TextEncoding,
pub people_list_strings: String,
}
impl FrameReaderDefault<IPLS> for IPLS {
fn read(readable: &mut Readable) -> Result<IPLS> {
let text_encoding = util::to_encoding(readable.u8()?);
let people_list_strings = util::read_null_terminated(&text_encoding, readable)?;
Ok(IPLS {
text_encoding: text_encoding,
people_list_strings: people_list_strings,
})
}
}
impl FrameWriterDefault for IPLS {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
writable.string(self.people_list_strings.as_str())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct LINK {
pub frame_identifier: String,
pub url: String,
pub additional_data: String,
}
impl FrameReaderVersionAware<LINK> for LINK {
fn read(readable: &mut Readable, version: u8) -> Result<LINK> {
let frame_id = match version {
2 | 3 => readable.string(3)?,
_ => readable.string(4)?,
};
let url = readable.non_utf16_string()?;
let additional_data = readable.all_string()?;
Ok(LINK {
frame_identifier: frame_id,
url: url,
additional_data: additional_data,
})
}
}
impl FrameWriterVersionAware<LINK> for LINK {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>, version: u8) -> Result<()> {
match version {
2 | 3 => writable.string(&self.frame_identifier[0..3])?,
_ => writable.string(&self.frame_identifier[0..4])?,
}
writable.string(self.url.as_str())?;
writable.string(self.additional_data.as_str())?;
Ok(())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MCDI {
pub cd_toc: Vec<u8>,
}
impl FrameReaderDefault<MCDI> for MCDI {
fn read(readable: &mut Readable) -> Result<MCDI> {
let cd_toc = readable.all_bytes()?;
Ok(MCDI { cd_toc: cd_toc })
}
}
impl FrameWriterDefault for MCDI {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.write(&self.cd_toc)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MLLT {
pub data: Vec<u8>,
}
impl FrameReaderDefault<MLLT> for MLLT {
fn read(readable: &mut Readable) -> Result<MLLT> {
let data = readable.all_bytes()?;
Ok(MLLT { data: data })
}
}
impl FrameWriterDefault for MLLT {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.write(&self.data)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct OWNE {
pub text_encoding: TextEncoding,
pub price_paid: String,
pub date_of_purch: String,
pub seller: String,
}
impl FrameReaderDefault<OWNE> for OWNE {
fn read(readable: &mut Readable) -> Result<OWNE> {
let text_encoding = util::to_encoding(readable.u8()?);
let price_paid = readable.non_utf16_string()?;
let date_of_purch = readable.string(4)?;
let seller = util::read_null_terminated(&text_encoding, readable)?;
Ok(OWNE {
text_encoding: text_encoding,
price_paid: price_paid,
date_of_purch: date_of_purch,
seller: seller,
})
}
}
impl FrameWriterDefault for OWNE {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
writable.non_utf16_string(self.price_paid.as_str())?;
writable.string(&self.date_of_purch[0..4])?;
util::write_null_terminated(&self.text_encoding, self.seller.as_str(), writable)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct PRIV {
pub owner_identifier: String,
pub private_data: Vec<u8>,
}
impl FrameReaderDefault<PRIV> for PRIV {
fn read(readable: &mut Readable) -> Result<PRIV> {
let owner_identifier = readable.non_utf16_string()?;
let private_data = readable.all_bytes()?;
Ok(PRIV {
owner_identifier: owner_identifier,
private_data: private_data,
})
}
}
impl FrameWriterDefault for PRIV {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.non_utf16_string(self.owner_identifier.as_str())?;
writable.write(&self.private_data)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct PCNT {
pub counter: u32,
}
impl FrameReaderDefault<PCNT> for PCNT {
fn read(readable: &mut Readable) -> Result<PCNT> {
let counter = readable.u32()?;
Ok(PCNT { counter: counter })
}
}
impl FrameWriterDefault for PCNT {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u32(self.counter)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct POPM {
pub email_to_user: String,
pub rating: u8,
pub counter: u32,
}
impl FrameReaderDefault<POPM> for POPM {
fn read(readable: &mut Readable) -> Result<POPM> {
let email_to_user = readable.non_utf16_string()?;
let rating = readable.u8()?;
let counter = readable.u32()?;
Ok(POPM {
email_to_user: email_to_user,
rating: rating,
counter: counter,
})
}
}
impl FrameWriterDefault for POPM {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.non_utf16_string(self.email_to_user.as_str())?;
writable.u8(self.rating)?;
writable.u32(self.counter)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct POSS {
pub timestamp_format: TimestampFormat,
pub position: Vec<u8>,
}
impl FrameReaderDefault<POSS> for POSS {
fn read(readable: &mut Readable) -> Result<POSS> {
let timestamp_format = util::to_timestamp_format(readable.u8()?);
let position = readable.all_bytes()?;
Ok(POSS {
timestamp_format: timestamp_format,
position: position,
})
}
}
impl FrameWriterDefault for POSS {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_timestamp_format(&self.timestamp_format))?;
writable.write(&self.position)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RBUF {
pub buffer_size: u32,
pub embedded_info_flag: u8,
pub offset_to_next_tag: u32,
}
impl FrameReaderDefault<RBUF> for RBUF {
fn read(readable: &mut Readable) -> Result<RBUF> {
let buffer_size = readable.u24()?;
let embedded_info_flag = readable.u8()?;
let offset_to_next_tag = readable.u32()?;
Ok(RBUF {
buffer_size: buffer_size,
embedded_info_flag: embedded_info_flag,
offset_to_next_tag: offset_to_next_tag,
})
}
}
impl FrameWriterDefault for RBUF {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u24(self.buffer_size)?;
writable.u8(self.embedded_info_flag)?;
writable.u32(self.offset_to_next_tag)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RVA2 {
pub data: Vec<u8>,
}
impl FrameReaderDefault<RVA2> for RVA2 {
fn read(readable: &mut Readable) -> Result<RVA2> {
let data = readable.all_bytes()?;
Ok(RVA2 { data: data })
}
}
impl FrameWriterDefault for RVA2 {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.write(&self.data)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct RVRB {
pub reverb_left: u16,
pub reverb_right: u16,
pub reverb_bounce_left: u8,
pub reverb_bounce_right: u8,
pub reverb_feedback_left_to_left: u8,
pub reverb_feedback_left_to_right: u8,
pub reverb_feedback_right_to_right: u8,
pub reverb_feedback_right_to_left: u8,
pub premix_left_to_right: u8,
pub premix_right_to_left: u8,
}
impl FrameReaderDefault<RVRB> for RVRB {
fn read(readable: &mut Readable) -> Result<RVRB> {
let reverb_left = readable.u16()?;
let reverb_right = readable.u16()?;
let reverb_bounce_left = readable.u8()?;
let reverb_bounce_right = readable.u8()?;
let reverb_feedback_left_to_left = readable.u8()?;
let reverb_feedback_left_to_right = readable.u8()?;
let reverb_feedback_right_to_right = readable.u8()?;
let reverb_feedback_right_to_left = readable.u8()?;
let premix_left_to_right = readable.u8()?;
let premix_right_to_left = readable.u8()?;
Ok(RVRB {
reverb_left: reverb_left,
reverb_right: reverb_right,
reverb_bounce_left: reverb_bounce_left,
reverb_bounce_right: reverb_bounce_right,
reverb_feedback_left_to_left: reverb_feedback_left_to_left,
reverb_feedback_left_to_right: reverb_feedback_left_to_right,
reverb_feedback_right_to_right: reverb_feedback_right_to_right,
reverb_feedback_right_to_left: reverb_feedback_right_to_left,
premix_left_to_right: premix_left_to_right,
premix_right_to_left: premix_right_to_left,
})
}
}
impl FrameWriterDefault for RVRB {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u16(self.reverb_left)?;
writable.u16(self.reverb_right)?;
writable.u8(self.reverb_bounce_left)?;
writable.u8(self.reverb_bounce_right)?;
writable.u8(self.reverb_feedback_left_to_left)?;
writable.u8(self.reverb_feedback_left_to_right)?;
writable.u8(self.reverb_feedback_right_to_right)?;
writable.u8(self.reverb_feedback_right_to_left)?;
writable.u8(self.premix_left_to_right)?;
writable.u8(self.premix_right_to_left)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SEEK {
pub next_tag: String,
}
impl FrameReaderDefault<SEEK> for SEEK {
fn read(readable: &mut Readable) -> Result<SEEK> {
let next_tag = readable.all_string()?;
Ok(SEEK { next_tag: next_tag })
}
}
impl FrameWriterDefault for SEEK {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.string(self.next_tag.as_str())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SIGN {
pub group_symbol: u8,
pub signature: Vec<u8>,
}
impl FrameReaderDefault<SIGN> for SIGN {
fn read(readable: &mut Readable) -> Result<SIGN> {
let group_symbol = readable.u8()?;
let signature = readable.all_bytes()?;
Ok(SIGN {
group_symbol: group_symbol,
signature: signature,
})
}
}
impl FrameWriterDefault for SIGN {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(self.group_symbol)?;
writable.write(&self.signature)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SYLT {
pub text_encoding: TextEncoding,
pub language: String,
pub timestamp_format: TimestampFormat,
pub content_type: ContentType,
pub content_descriptor: String,
}
impl FrameReaderDefault<SYLT> for SYLT {
fn read(readable: &mut Readable) -> Result<SYLT> {
let text_encoding = util::to_encoding(readable.u8()?);
let language = readable.string(3)?;
let timestamp_format = util::to_timestamp_format(readable.u8()?);
let content_type = util::to_content_type(readable.u8()?);
let content_descriptor = util::read_null_terminated(&text_encoding, readable)?;
Ok(SYLT {
text_encoding: text_encoding,
language: language,
timestamp_format: timestamp_format,
content_type: content_type,
content_descriptor: content_descriptor,
})
}
}
impl FrameWriterDefault for SYLT {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
writable.string(&self.language[0..3])?;
writable.u8(util::from_timestamp_format(&self.timestamp_format))?;
writable.u8(util::from_content_type(&self.content_type))?;
util::write_null_terminated(&self.text_encoding,
self.content_descriptor.as_str(),
writable)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct SYTC {
pub timestamp_format: TimestampFormat,
pub tempo_data: Vec<u8>,
}
impl FrameReaderDefault<SYTC> for SYTC {
fn read(readable: &mut Readable) -> Result<SYTC> {
let timestamp_format = util::to_timestamp_format(readable.u8()?);
let tempo_data = readable.all_bytes()?;
Ok(SYTC {
timestamp_format: timestamp_format,
tempo_data: tempo_data,
})
}
}
impl FrameWriterDefault for SYTC {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_timestamp_format(&self.timestamp_format))?;
writable.write(&self.tempo_data)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct UFID {
pub owner_identifier: String,
pub identifier: Vec<u8>,
}
impl FrameReaderDefault<UFID> for UFID {
fn read(readable: &mut Readable) -> Result<UFID> {
let owner_identifier = readable.non_utf16_string()?;
let identifier = readable.all_bytes()?;
Ok(UFID {
owner_identifier: owner_identifier,
identifier: identifier,
})
}
}
impl FrameWriterDefault for UFID {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.non_utf16_string(self.owner_identifier.as_str())?;
writable.write(&self.identifier)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct USER {
pub text_encoding: TextEncoding,
pub language: String,
pub actual_text: String,
}
impl FrameReaderDefault<USER> for USER {
fn read(readable: &mut Readable) -> Result<USER> {
let text_encoding = util::to_encoding(readable.u8()?);
let language = readable.string(3)?;
let actual_text = util::read_null_terminated(&text_encoding, readable)?;
Ok(USER {
text_encoding: text_encoding,
language: language,
actual_text: actual_text,
})
}
}
impl FrameWriterDefault for USER {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
writable.string(&self.language[0..3])?;
util::write_null_terminated(&self.text_encoding, self.actual_text.as_str(), writable)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct USLT {
pub text_encoding: TextEncoding,
pub language: String,
pub content_descriptor: String,
pub lyrics: String,
}
impl FrameReaderDefault<USLT> for USLT {
fn read(readable: &mut Readable) -> Result<USLT> {
let text_encoding = util::to_encoding(readable.u8()?);
let language = readable.string(3)?;
let content_descriptor = util::read_null_terminated(&text_encoding, readable)?;
let lyrics = util::read_null_terminated(&text_encoding, readable)?;
Ok(USLT {
text_encoding: text_encoding,
language: language,
content_descriptor: content_descriptor,
lyrics: lyrics,
})
}
}
impl FrameWriterDefault for USLT {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
writable.string(&self.language[0..3])?;
util::write_null_terminated(&self.text_encoding,
self.content_descriptor.as_str(),
writable)?;
util::write_null_terminated(&self.text_encoding, self.lyrics.as_str(), writable)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TEXT {
pub text_encoding: TextEncoding,
pub text: String,
}
impl FrameReaderIdAware<TEXT> for TEXT {
fn read(readable: &mut Readable, id: &str) -> Result<TEXT> {
fn _default(id: &str,
decode: ::std::result::Result<String, ::std::borrow::Cow<'static, str>>)
-> String {
match decode {
Ok(text) => text,
Err(e) => {
debug!("TEXT Error {}, {:?}", id, e);
if id == id::TBPM_STR || id == id::TBP_STR {
"0".to_string()
} else {
"".to_string()
}
}
}
}
let text_encoding = util::to_encoding(readable.u8()?);
let data = readable.all_bytes()?;
let text = match text_encoding {
TextEncoding::ISO88591 => _default(id, ISO_8859_1.decode(&data, DecoderTrap::Strict)),
TextEncoding::UTF16LE => _default(id, UTF_16LE.decode(&data, DecoderTrap::Strict)),
TextEncoding::UTF16BE => _default(id, UTF_16BE.decode(&data, DecoderTrap::Strict)),
TextEncoding::UTF8 => _default(id, UTF_8.decode(&data, DecoderTrap::Strict)),
};
Ok(TEXT {
text_encoding: text_encoding,
text: self::trim(text),
})
}
}
impl FrameWriterDefault for TEXT {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
let text = match match self.text_encoding {
TextEncoding::ISO88591 => ISO_8859_1.encode(self.text.as_str(), EncoderTrap::Strict),
TextEncoding::UTF16LE => UTF_16LE.encode(self.text.as_str(), EncoderTrap::Strict),
TextEncoding::UTF16BE => UTF_16BE.encode(self.text.as_str(), EncoderTrap::Strict),
TextEncoding::UTF8 => UTF_8.encode(self.text.as_str(), EncoderTrap::Strict),
} {
Ok(text) => text,
Err(msg) => return Err(Error::new(ErrorKind::InvalidInput, msg.to_owned().to_string())),
};
match self.text_encoding {
TextEncoding::UTF16LE => {
writable.u8(0xff)?;
writable.u8(0xfe)?;
}
_ => (),
}
writable.write(&text)?;
match self.text_encoding {
TextEncoding::UTF16BE => {
writable.u8(0xfe)?;
writable.u8(0xff)?;
}
_ => (),
}
Ok(())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TXXX {
pub text_encoding: TextEncoding,
pub description: String,
pub value: String,
}
impl FrameReaderDefault<TXXX> for TXXX {
fn read(readable: &mut Readable) -> Result<TXXX> {
let text_encoding = util::to_encoding(readable.u8()?);
let description = util::read_null_terminated(&text_encoding, readable)?;
let value = readable.all_string()?;
Ok(TXXX {
text_encoding: text_encoding,
description: description,
value: value,
})
}
}
impl FrameWriterDefault for TXXX {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
util::write_null_terminated(&self.text_encoding, self.description.as_str(), writable)?;
writable.string(self.value.as_str())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct WXXX {
pub text_encoding: TextEncoding,
pub description: String,
pub url: String,
}
impl FrameReaderDefault<WXXX> for WXXX {
fn read(readable: &mut Readable) -> Result<WXXX> {
let text_encoding = util::to_encoding(readable.u8()?);
let description = util::read_null_terminated(&text_encoding, readable)?;
let url = readable.all_string()?;
Ok(WXXX {
text_encoding: text_encoding,
description: description,
url: url,
})
}
}
impl FrameWriterDefault for WXXX {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.u8(util::from_encoding(&self.text_encoding))?;
util::write_null_terminated(&self.text_encoding, self.description.as_str(), writable)?;
writable.string(self.url.as_str())
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct OBJECT {
pub data: Vec<u8>,
}
impl FrameWriterDefault for OBJECT {
fn write(&self, writable: &mut Writable<Cursor<Vec<u8>>>) -> Result<()> {
writable.write(&self.data)
}
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum FrameBody {
BUF(RBUF),
CRM(CRM),
PIC(PIC),
AENC(AENC),
APIC(APIC),
ASPI(ASPI),
COMM(COMM),
COMR(COMR),
ENCR(ENCR),
EQUA(EQUA),
EQU2(EQU2),
ETCO(ETCO),
GEOB(GEOB),
GRID(GRID),
IPLS(IPLS),
LINK(LINK),
MCDI(MCDI),
MLLT(MLLT),
OWNE(OWNE),
PRIV(PRIV),
PCNT(PCNT),
POPM(POPM),
POSS(POSS),
RBUF(RBUF),
RVAD(RVA2),
RVA2(RVA2),
RVRB(RVRB),
SEEK(SEEK),
SIGN(SIGN),
SYLT(SYLT),
SYTC(SYTC),
TALB(TEXT),
TBPM(TEXT),
TCOM(TEXT),
TCON(TEXT),
TCOP(TEXT),
TDAT(TEXT),
TDEN(TEXT),
TDLY(TEXT),
TDOR(TEXT),
TDRC(TEXT),
TDRL(TEXT),
TDTG(TEXT),
TENC(TEXT),
TEXT(TEXT),
TFLT(TEXT),
TIME(TEXT),
TIPL(TEXT),
TIT1(TEXT),
TIT2(TEXT),
TIT3(TEXT),
TKEY(TEXT),
TLAN(TEXT),
TLEN(TEXT),
TMCL(TEXT),
TMED(TEXT),
TMOO(TEXT),
TOAL(TEXT),
TOFN(TEXT),
TOLY(TEXT),
TOPE(TEXT),
TORY(TEXT),
TOWN(TEXT),
TPE1(TEXT),
TPE2(TEXT),
TPE3(TEXT),
TPE4(TEXT),
TPOS(TEXT),
TPRO(TEXT),
TPUB(TEXT),
TRCK(TEXT),
TRDA(TEXT),
TRSN(TEXT),
TRSO(TEXT),
TSIZ(TEXT),
TSOA(TEXT),
TSOP(TEXT),
TSOT(TEXT),
TSRC(TEXT),
TSSE(TEXT),
TYER(TEXT),
TSST(TEXT),
TXXX(TXXX),
UFID(UFID),
USER(USER),
USLT(USLT),
WCOM(LINK),
WCOP(LINK),
WOAF(LINK),
WOAR(LINK),
WOAS(LINK),
WORS(LINK),
WPAY(LINK),
WPUB(LINK),
WXXX(WXXX),
OBJECT(OBJECT),
SKIP(String, Vec<u8>),
INVALID(String),
}
pub mod id {
pub const BUF_STR: &'static str = "BUF";
pub const CNT_STR: &'static str = "CNT";
pub const COM_STR: &'static str = "COM";
pub const CRA_STR: &'static str = "CRA";
pub const CRM_STR: &'static str = "CRM";
pub const ETC_STR: &'static str = "ETC";
pub const EQU_STR: &'static str = "EQU";
pub const GEO_STR: &'static str = "GEO";
pub const IPL_STR: &'static str = "IPL";
pub const LNK_STR: &'static str = "LNK";
pub const MCI_STR: &'static str = "MCI";
pub const MLL_STR: &'static str = "MLL";
pub const PIC_STR: &'static str = "PIC";
pub const POP_STR: &'static str = "POP";
pub const REV_STR: &'static str = "REV";
pub const RVA_STR: &'static str = "RVA";
pub const SLT_STR: &'static str = "SLT";
pub const STC_STR: &'static str = "STC";
pub const TAL_STR: &'static str = "TAL";
pub const TBP_STR: &'static str = "TBP";
pub const TCM_STR: &'static str = "TCM";
pub const TCO_STR: &'static str = "TCO";
pub const TCR_STR: &'static str = "TCR";
pub const TDA_STR: &'static str = "TDA";
pub const TDY_STR: &'static str = "TDY";
pub const TEN_STR: &'static str = "TEN";
pub const TFT_STR: &'static str = "TFT";
pub const TIM_STR: &'static str = "TIM";
pub const TKE_STR: &'static str = "TKE";
pub const TLA_STR: &'static str = "TLA";
pub const TLE_STR: &'static str = "TLE";
pub const TMT_STR: &'static str = "TMT";
pub const TOA_STR: &'static str = "TOA";
pub const TOF_STR: &'static str = "TOF";
pub const TOL_STR: &'static str = "TOL";
pub const TOR_STR: &'static str = "TOR";
pub const TOT_STR: &'static str = "TOT";
pub const TP1_STR: &'static str = "TP1";
pub const TP2_STR: &'static str = "TP2";
pub const TP3_STR: &'static str = "TP3";
pub const TP4_STR: &'static str = "TP4";
pub const TPA_STR: &'static str = "TPA";
pub const TPB_STR: &'static str = "TPB";
pub const TRC_STR: &'static str = "TRC";
pub const TRD_STR: &'static str = "TRD";
pub const TRK_STR: &'static str = "TRK";
pub const TSI_STR: &'static str = "TSI";
pub const TSS_STR: &'static str = "TSS";
pub const TT1_STR: &'static str = "TT1";
pub const TT2_STR: &'static str = "TT2";
pub const TT3_STR: &'static str = "TT3";
pub const TXT_STR: &'static str = "TXT";
pub const TXX_STR: &'static str = "TXX";
pub const TYE_STR: &'static str = "TYE";
pub const UFI_STR: &'static str = "UFI";
pub const ULT_STR: &'static str = "ULT";
pub const WAF_STR: &'static str = "WAF";
pub const WAR_STR: &'static str = "WAR";
pub const WAS_STR: &'static str = "WAS";
pub const WCM_STR: &'static str = "WCM";
pub const WCP_STR: &'static str = "WCP";
pub const WPB_STR: &'static str = "WPB";
pub const WXX_STR: &'static str = "WXX";
pub const AENC_STR: &'static str = "AENC";
pub const APIC_STR: &'static str = "APIC";
pub const ASPI_STR: &'static str = "ASPI";
pub const COMM_STR: &'static str = "COMM";
pub const COMR_STR: &'static str = "COMR";
pub const ENCR_STR: &'static str = "ENCR";
pub const EQU2_STR: &'static str = "EQU2";
pub const EQUA_STR: &'static str = "EQUA";
pub const ETCO_STR: &'static str = "ETCO";
pub const GEOB_STR: &'static str = "GEOB";
pub const GRID_STR: &'static str = "GRID";
pub const IPLS_STR: &'static str = "IPLS";
pub const LINK_STR: &'static str = "LINK";
pub const MCDI_STR: &'static str = "MCDI";
pub const MLLT_STR: &'static str = "MLLT";
pub const OWNE_STR: &'static str = "OWNE";
pub const PRIV_STR: &'static str = "PRIV";
pub const PCNT_STR: &'static str = "PCNT";
pub const POPM_STR: &'static str = "POPM";
pub const POSS_STR: &'static str = "POSS";
pub const RBUF_STR: &'static str = "RBUF";
pub const RVAD_STR: &'static str = "RVAD";
pub const RVA2_STR: &'static str = "RVA2";
pub const RVRB_STR: &'static str = "RVRB";
pub const SEEK_STR: &'static str = "SEEK";
pub const SIGN_STR: &'static str = "SIGN";
pub const SYLT_STR: &'static str = "SYLT";
pub const SYTC_STR: &'static str = "SYTC";
pub const TALB_STR: &'static str = "TALB";
pub const TBPM_STR: &'static str = "TBPM";
pub const TCOM_STR: &'static str = "TCOM";
pub const TCON_STR: &'static str = "TCON";
pub const TCOP_STR: &'static str = "TCOP";
pub const TDAT_STR: &'static str = "TDAT";
pub const TDEN_STR: &'static str = "TDEN";
pub const TDLY_STR: &'static str = "TDLY";
pub const TDOR_STR: &'static str = "TDOR";
pub const TDRC_STR: &'static str = "TDRC";
pub const TDTG_STR: &'static str = "TDTG";
pub const TDRL_STR: &'static str = "TDRL";
pub const TENC_STR: &'static str = "TENC";
pub const TEXT_STR: &'static str = "TEXT";
pub const TFLT_STR: &'static str = "TFLT";
pub const TIME_STR: &'static str = "TIME";
pub const TIPL_STR: &'static str = "TIPL";
pub const TIT1_STR: &'static str = "TIT1";
pub const TIT2_STR: &'static str = "TIT2";
pub const TIT3_STR: &'static str = "TIT3";
pub const TKEY_STR: &'static str = "TKEY";
pub const TLAN_STR: &'static str = "TLAN";
pub const TLEN_STR: &'static str = "TLEN";
pub const TMCL_STR: &'static str = "TMCL";
pub const TMED_STR: &'static str = "TMED";
pub const TMOO_STR: &'static str = "TMOO";
pub const TOAL_STR: &'static str = "TOAL";
pub const TOFN_STR: &'static str = "TOFN";
pub const TOLY_STR: &'static str = "TOLY";
pub const TOPE_STR: &'static str = "TOPE";
pub const TORY_STR: &'static str = "TORY";
pub const TOWN_STR: &'static str = "TOWN";
pub const TPE1_STR: &'static str = "TPE1";
pub const TPE2_STR: &'static str = "TPE2";
pub const TPE3_STR: &'static str = "TPE3";
pub const TPE4_STR: &'static str = "TPE4";
pub const TPOS_STR: &'static str = "TPOS";
pub const TPRO_STR: &'static str = "TPRO";
pub const TPUB_STR: &'static str = "TPUB";
pub const TRCK_STR: &'static str = "TRCK";
pub const TRDA_STR: &'static str = "TRDA";
pub const TRSN_STR: &'static str = "TRSN";
pub const TRSO_STR: &'static str = "TRSO";
pub const TSIZ_STR: &'static str = "TSIZ";
pub const TSOA_STR: &'static str = "TSOA";
pub const TSOP_STR: &'static str = "TSOP";
pub const TSOT_STR: &'static str = "TSOT";
pub const TSRC_STR: &'static str = "TSRC";
pub const TSSE_STR: &'static str = "TSSE";
pub const TYER_STR: &'static str = "TYER";
pub const TSST_STR: &'static str = "TSST";
pub const TXXX_STR: &'static str = "TXXX";
pub const UFID_STR: &'static str = "UFID";
pub const USER_STR: &'static str = "USER";
pub const USLT_STR: &'static str = "USLT";
pub const WCOM_STR: &'static str = "WCOM";
pub const WCOP_STR: &'static str = "WCOP";
pub const WOAF_STR: &'static str = "WOAF";
pub const WOAR_STR: &'static str = "WOAR";
pub const WOAS_STR: &'static str = "WOAS";
pub const WORS_STR: &'static str = "WORS";
pub const WPAY_STR: &'static str = "WPAY";
pub const WPUB_STR: &'static str = "WPUB";
pub const WXXX_STR: &'static str = "WXXX";
}