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
use std::io::Write;
use std::collections::HashMap;
use std::str::FromStr;
use std::fmt;
use super::*;
use std::f32;
macro_rules! write_some_attribute_quoted {
($w:expr, $tag:expr, $o:expr) => (
if let &Some(ref v) = $o { write!($w, "{}=\"{}\"", $tag, v) } else { Ok(()) }
);
}
macro_rules! write_some_attribute {
($w:expr, $tag:expr, $o:expr) => (
if let &Some(ref v) = $o { write!($w, "{}={}", $tag, v) } else { Ok(()) }
);
}
macro_rules! bool_default_false {
($optional:expr) => (
match $optional {
Some(ref s) if s == "YES" => true,
Some(_) | None => false,
}
);
}
#[derive(Debug, PartialEq)]
pub enum Playlist {
MasterPlaylist(MasterPlaylist),
MediaPlaylist(MediaPlaylist),
}
impl Playlist {
pub fn write_to<T: Write>(&self, writer: &mut T) -> std::io::Result<()> {
match self {
&Playlist::MasterPlaylist(ref pl) => pl.write_to(writer),
&Playlist::MediaPlaylist(ref pl) => pl.write_to(writer),
}
}
}
#[derive(Debug, Default, PartialEq)]
pub struct MasterPlaylist {
pub version: usize,
pub variants: Vec<VariantStream>,
pub session_data: Option<SessionData>,
pub session_key: Option<SessionKey>,
pub start: Option<Start>,
pub independent_segments: bool,
}
impl MasterPlaylist {
pub fn from_tags(mut tags: Vec<MasterPlaylistTag>) -> MasterPlaylist {
let mut master_playlist = MasterPlaylist::default();
let mut alternatives = vec![];
while let Some(tag) = tags.pop() {
match tag {
MasterPlaylistTag::Version(v) => {
master_playlist.version = v;
}
MasterPlaylistTag::AlternativeMedia(v) => {
alternatives.push(v);
}
MasterPlaylistTag::VariantStream(mut stream) => {
stream.alternatives = alternatives;
alternatives = vec![];
master_playlist.variants.push(stream);
}
MasterPlaylistTag::Uri(uri) => {
if let Some(stream) = master_playlist.get_newest_variant() {
stream.uri = uri;
}
}
MasterPlaylistTag::SessionData(data) => {
master_playlist.session_data = Some(data);
}
MasterPlaylistTag::SessionKey(key) => {
master_playlist.session_key = Some(key);
}
MasterPlaylistTag::Start(s) => {
master_playlist.start = Some(s);
}
MasterPlaylistTag::IndependentSegments => {
master_playlist.independent_segments = true;
}
MasterPlaylistTag::Unknown(_) => {
}
_ => (),
}
}
master_playlist
}
fn get_newest_variant(&mut self) -> Option<&mut VariantStream> {
self.variants.iter_mut().rev().find(|v| !v.is_i_frame)
}
pub fn write_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
writeln!(w, "{}" ,"#EXTM3U")?;
writeln!(w, "#EXT-X-VERSION:{}", self.version)?;
for variant in &self.variants {
variant.write_to(w)?;
}
if let Some(ref session_data) = self.session_data {
session_data.write_to(w)?;
}
if let Some(ref session_key) = self.session_key {
session_key.write_to(w)?;
}
if let Some(ref start) = self.start {
start.write_to(w)?;
}
if self.independent_segments {
writeln!(w, "#EXT-X-INDEPENDENT-SEGMENTS")?;
}
Ok(())
}
}
#[derive(Debug, Default, PartialEq)]
pub struct VariantStream {
pub is_i_frame: bool,
pub uri: String,
pub bandwidth: String,
pub average_bandwidth: Option<String>,
pub codecs: String,
pub resolution: Option<String>,
pub frame_rate: Option<String>,
pub audio: Option<String>,
pub video: Option<String>,
pub subtitles: Option<String>,
pub closed_captions: Option<String>,
pub alternatives: Vec<AlternativeMedia>,
}
impl VariantStream {
pub fn from_hashmap(mut attrs: HashMap<String, String>, is_i_frame: bool) -> VariantStream {
VariantStream {
is_i_frame: is_i_frame,
uri: attrs.remove("URI").unwrap_or_else(String::new),
bandwidth: attrs.remove("BANDWIDTH").unwrap_or_else(String::new),
average_bandwidth: attrs.remove("AVERAGE-BANDWIDTH"),
codecs: attrs.remove("CODECS").unwrap_or_else(String::new),
resolution: attrs.remove("RESOLUTION"),
frame_rate: attrs.remove("FRAME-RATE"),
audio: attrs.remove("AUDIO"),
video: attrs.remove("VIDEO"),
subtitles: attrs.remove("SUBTITLES"),
closed_captions: attrs.remove("CLOSED-CAPTIONS"),
alternatives: vec![],
}
}
pub fn write_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
for alternative in &self.alternatives {
alternative.write_to(w)?;
}
if self.is_i_frame {
write!(w, "#EXT-X-I-FRAME-STREAM-INF:")?;
self.write_stream_inf_common_attributes(w)?;
writeln!(w, "URI=\"{}\"", self.uri)
}
else {
write!(w, "#EXT-X-STREAM-INF:")?;
self.write_stream_inf_common_attributes(w)?;
write_some_attribute_quoted!(w, ",AUDIO", &self.audio)?;
write_some_attribute_quoted!(w, ",SUBTITLES", &self.subtitles)?;
write_some_attribute_quoted!(w, ",CLOSED-CAPTIONS", &self.closed_captions)?;
write!(w, "\n")?;
writeln!(w, "{}", self.uri)
}
}
fn write_stream_inf_common_attributes<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
write!(w, "BANDWIDTH={}", &self.bandwidth)?;
write_some_attribute!(w, ",AVERAGE-BANDWIDTH", &self.average_bandwidth)?;
write!(w, ",CODECS=\"{}\"", &self.codecs)?;
write_some_attribute!(w, ",RESOLUTION", &self.resolution)?;
write_some_attribute!(w, ",FRAME-RATE", &self.frame_rate)?;
write_some_attribute_quoted!(w, ",VIDEO", &self.video)
}
}
#[derive(Debug, Default, PartialEq)]
pub struct AlternativeMedia {
pub media_type: AlternativeMediaType,
pub uri: Option<String>,
pub group_id: String,
pub language: Option<String>,
pub assoc_language: Option<String>,
pub name: String,
pub default: bool,
pub autoselect: bool,
pub forced: bool,
pub instream_id: Option<String>,
pub characteristics: Option<String>,
}
impl AlternativeMedia {
pub fn from_hashmap(mut attrs: HashMap<String, String>) -> AlternativeMedia {
AlternativeMedia {
media_type: attrs.get("TYPE")
.and_then(|s| AlternativeMediaType::from_str(s).ok())
.unwrap_or_else(Default::default),
uri: attrs.remove("URI"),
group_id: attrs.remove("GROUP-ID").unwrap_or_else(String::new),
language: attrs.remove("LANGUAGE"),
assoc_language: attrs.remove("ASSOC-LANGUAGE"),
name: attrs.remove("NAME").unwrap_or(String::new()),
default: bool_default_false!(attrs.remove("DEFAULT")),
autoselect: bool_default_false!(attrs.remove("AUTOSELECT")),
forced: bool_default_false!(attrs.remove("FORCED")),
instream_id: attrs.remove("INSTREAM-ID"),
characteristics: attrs.remove("CHARACTERISTICS"),
}
}
pub fn write_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
write!(w, "#EXT-X-MEDIA:")?;
write!(w, "TYPE={}", self.media_type)?;
write_some_attribute_quoted!(w, ",URI", &self.uri)?;
write!(w, ",GROUP-ID=\"{}\"", self.group_id)?;
write_some_attribute_quoted!(w, ",LANGUAGE", &self.language)?;
write_some_attribute_quoted!(w, ",ASSOC-LANGUAGE", &self.assoc_language)?;
write!(w, ",NAME=\"{}\"", self.name)?;
if self.default { write!(w, ",DEFAULT=YES")?; }
if self.autoselect { write!(w, ",AUTOSELECT=YES")?; }
if self.forced { write!(w, ",FORCED=YES")?; }
write_some_attribute_quoted!(w, ",INSTREAM-ID", &self.instream_id)?;
write_some_attribute_quoted!(w, ",CHARACTERISTICS", &self.characteristics)?;
write!(w, "\n")
}
}
#[derive(Debug, PartialEq)]
pub enum AlternativeMediaType {
Audio,
Video,
Subtitles,
ClosedCaptions,
}
impl FromStr for AlternativeMediaType {
type Err = String;
fn from_str(s: &str) -> Result<AlternativeMediaType, String> {
match s {
"AUDIO" => Ok(AlternativeMediaType::Audio),
"VIDEO" => Ok(AlternativeMediaType::Video),
"SUBTITLES" => Ok(AlternativeMediaType::Subtitles),
"CLOSEDCAPTIONS" => Ok(AlternativeMediaType::ClosedCaptions),
_ => Err(format!("Unable to create AlternativeMediaType from {:?}", s)),
}
}
}
impl Default for AlternativeMediaType {
fn default() -> AlternativeMediaType {
AlternativeMediaType::Video
}
}
impl fmt::Display for AlternativeMediaType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", match self {
&AlternativeMediaType::Audio => "AUDIO",
&AlternativeMediaType::Video => "VIDEO",
&AlternativeMediaType::Subtitles => "SUBTITLES",
&AlternativeMediaType::ClosedCaptions => "CLOSEDCAPTIONS",
})
}
}
#[derive(Debug, Default, PartialEq)]
pub struct SessionKey(pub Key);
impl SessionKey {
pub fn write_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
write!(w, "#EXT-X-SESSION-KEY:")?;
self.0.write_attributes_to(w)?;
write!(w, "\n")
}
}
#[derive(Debug, Default, PartialEq)]
pub struct SessionData {
pub data_id: String,
pub value: String,
pub uri: String,
pub language: Option<String>,
}
impl SessionData {
pub fn from_hashmap(mut attrs: HashMap<String, String>) -> SessionData {
SessionData {
data_id: attrs.remove("DATA-ID").unwrap_or_else(String::new),
value: attrs.remove("VALUE").unwrap_or_else(String::new),
uri: attrs.remove("URI").unwrap_or_else(String::new),
language: attrs.remove("LANGUAGE"),
}
}
pub fn write_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
write!(w, "#EXT-X-SESSION-DATA:")?;
write!(w, "DATA-ID=\"{}\"", self.data_id)?;
write!(w, ",VALUE=\"{}\"", self.value)?;
write!(w, ",URI=\"{}\"", self.uri)?;
write_some_attribute_quoted!(w, ",LANGUAGE", &self.language)?;
write!(w, "\n")
}
}
#[derive(Debug, Default, PartialEq)]
pub struct MediaPlaylist {
pub version: usize,
pub target_duration: f32,
pub media_sequence: i32,
pub segments: Vec<MediaSegment>,
pub discontinuity_sequence: i32,
pub end_list: bool,
pub playlist_type: Option<MediaPlaylistType>,
pub i_frames_only: bool,
pub start: Option<Start>,
pub independent_segments: bool,
}
impl MediaPlaylist {
pub fn from_tags(mut tags: Vec<MediaPlaylistTag>) -> MediaPlaylist {
let mut media_playlist = MediaPlaylist::default();
let mut next_segment = MediaSegment::empty();
let mut encryption_key = None;
let mut map = None;
while let Some(tag) = tags.pop() {
println!("Tag: {:?}\n", &tag);
match tag {
MediaPlaylistTag::Version(v) => {
media_playlist.version = v;
}
MediaPlaylistTag::TargetDuration(d) => {
media_playlist.target_duration = d;
}
MediaPlaylistTag::MediaSequence(n) => {
media_playlist.media_sequence = n;
}
MediaPlaylistTag::DiscontinuitySequence(n) => {
media_playlist.discontinuity_sequence = n;
}
MediaPlaylistTag::EndList => {
media_playlist.end_list = true;
}
MediaPlaylistTag::PlaylistType(t) => {
media_playlist.playlist_type = Some(t);
}
MediaPlaylistTag::IFramesOnly => {
media_playlist.i_frames_only = true;
}
MediaPlaylistTag::Start(s) => {
media_playlist.start = Some(s);
}
MediaPlaylistTag::IndependentSegments => {
media_playlist.independent_segments = true;
}
MediaPlaylistTag::Segment(segment_tag) => {
match segment_tag {
SegmentTag::Extinf(d, t) => {
next_segment.duration = d;
next_segment.title = t;
}
SegmentTag::ByteRange(b) => {
next_segment.byte_range = Some(b);
}
SegmentTag::Discontinuity => {
next_segment.discontinuity = true;
}
SegmentTag::Key(k) => {
encryption_key = Some(k);
}
SegmentTag::Map(m) => {
map = Some(m);
}
SegmentTag::ProgramDateTime(d) => {
next_segment.program_date_time = Some(d);
}
SegmentTag::DateRange(d) => {
next_segment.daterange = Some(d);
}
SegmentTag::Uri(u) => {
next_segment.key = encryption_key.clone();
next_segment.map = map.clone();
next_segment.uri = u;
media_playlist.segments.push(next_segment);
next_segment = MediaSegment::empty();
}
_ => (),
}
}
_ => (),
}
}
media_playlist
}
pub fn write_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
writeln!(w, "{}" ,"#EXTM3U")?;
writeln!(w, "#EXT-X-VERSION:{}", self.version)?;
writeln!(w, "#EXT-X-TARGETDURATION:{}", self.target_duration)?;
if self.media_sequence != 0 {
writeln!(w, "#EXT-X-MEDIA-SEQUENCE:{}", self.media_sequence)?;
}
if self.discontinuity_sequence != 0 {
writeln!(w, "#EXT-X-DISCONTINUITY-SEQUENCE:{}", self.discontinuity_sequence)?;
}
if self.end_list {
writeln!(w, "#EXT-X-ENDLIST")?;
}
if let Some(ref v) = self.playlist_type {
writeln!(w, "#EXT-X-PLAYLIST-TYPE:{}", v)?;
}
if self.i_frames_only {
writeln!(w, "#EXT-X-I-FRAMES-ONLY")?;
}
if let Some(ref start) = self.start {
start.write_to(w)?;
}
if self.independent_segments {
writeln!(w, "#EXT-X-INDEPENDENT-SEGMENTS")?;
}
for segment in &self.segments {
segment.write_to(w)?;
}
Ok(())
}
}
#[derive(Debug, PartialEq)]
pub enum MediaPlaylistType {
Event,
Vod,
}
impl FromStr for MediaPlaylistType {
type Err = String;
fn from_str(s: &str) -> Result<MediaPlaylistType, String> {
match s {
"EVENT" => Ok(MediaPlaylistType::Event),
"VOD" => Ok(MediaPlaylistType::Vod),
_ => Err(format!("Unable to create MediaPlaylistType from {:?}", s)),
}
}
}
impl fmt::Display for MediaPlaylistType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", match self {
&MediaPlaylistType::Event => "EVENT",
&MediaPlaylistType::Vod => "VOD",
})
}
}
impl Default for MediaPlaylistType {
fn default() -> MediaPlaylistType {
MediaPlaylistType::Event
}
}
#[derive(Debug, Default, PartialEq)]
pub struct MediaSegment {
pub uri: String,
pub duration: f32,
pub title: Option<String>,
pub byte_range: Option<ByteRange>,
pub discontinuity: bool,
pub key: Option<Key>,
pub map: Option<Map>,
pub program_date_time: Option<String>,
pub daterange: Option<String>,
}
impl MediaSegment {
pub fn empty() -> MediaSegment {
Default::default()
}
pub fn write_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
if let Some(ref byte_range) = self.byte_range {
write!(w, "#EXT-X-BYTERANGE:")?;
byte_range.write_value_to(w)?;
write!(w, "\n")?;
}
if self.discontinuity {
writeln!(w, "{}", "#EXT-X-DISCONTINUITY")?;
}
if let Some(ref key) = self.key {
write!(w, "#EXT-X-KEY:")?;
key.write_attributes_to(w)?;
write!(w, "\n")?;
}
if let Some(ref map) = self.map {
write!(w, "#EXT-X-MAP:")?;
map.write_attributes_to(w)?;
write!(w, "\n")?;
}
if let Some(ref v) = self.program_date_time {
writeln!(w, "#EXT-X-PROGRAM-DATE-TIME:{}", v)?;
}
if let Some(ref v) = self.daterange {
writeln!(w, "#EXT-X-DATERANGE:{}", v)?;
}
write!(w, "#EXTINF:{},", self.duration)?;
if let Some(ref v) = self.title {
writeln!(w, "{}", v)?;
}
writeln!(w, "{}", self.uri)
}
}
#[derive(Debug, Default, Clone, PartialEq)]
pub struct Key {
pub method: String,
pub uri: Option<String>,
pub iv: Option<String>,
pub keyformat: Option<String>,
pub keyformatversions: Option<String>,
}
impl Key {
pub fn from_hashmap(mut attrs: HashMap<String, String>) -> Key {
Key {
method: attrs.remove("METHOD").unwrap_or_else(String::new),
uri: attrs.remove("URI"),
iv: attrs.remove("IV"),
keyformat: attrs.remove("KEYFORMAT"),
keyformatversions: attrs.remove("KEYFORMATVERSIONS"),
}
}
pub fn write_attributes_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
write!(w, "METHOD={}", self.method)?;
write_some_attribute_quoted!(w, ",URI", &self.uri)?;
write_some_attribute!(w, ",IV", &self.iv)?;
write_some_attribute!(w, ",KEYFORMAT", &self.keyformat)?;
write_some_attribute!(w, ",KEYFORMATVERSIONS", &self.keyformatversions)
}
}
#[derive(Debug, Default, Clone, PartialEq)]
pub struct Map {
pub uri: String,
pub byte_range: Option<ByteRange>,
}
impl Map {
pub fn from_hashmap(mut attrs: HashMap<String, String>) -> Map {
Map {
uri: attrs.remove("URI").unwrap_or_default(),
byte_range: attrs.remove("BYTERANGE").map(ByteRange::from),
}
}
pub fn write_attributes_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
write!(w, "URI=\"{}\"", self.uri)?;
if let Some(ref byte_range) = self.byte_range {
write!(w, ",BYTERANGE=")?;
byte_range.write_value_to(w)?;
}
Ok(())
}
}
#[derive(Debug, Default, Clone, PartialEq)]
pub struct ByteRange {
pub length: i32,
pub offset: Option<i32>,
}
impl ByteRange {
pub fn write_value_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
write!(w, "{}", self.length)?;
if let Some(offset) = self.offset {
write!(w, "@{}", offset)?;
}
Ok(())
}
}
impl From<String> for ByteRange {
fn from(s: String) -> Self {
let w: &str = &s;
ByteRange::from(w)
}
}
impl<'a> From<&'a str> for ByteRange {
fn from(s: &'a str) -> Self {
match byte_range_val(s.as_bytes()) {
IResult::Done(_, br) => br,
_ => panic!("Should not happen"),
}
}
}
#[derive(Debug, Default, PartialEq)]
pub struct DateRange {
pub id: String,
pub class: Option<String>,
pub start_date: String,
pub end_date: Option<String>,
pub duration: Option<String>,
pub planned_duration: Option<String>,
pub x_prefixed: Option<String>,
pub end_on_next: bool,
}
#[derive(Debug, Default, PartialEq)]
pub struct Start {
pub time_offset: String,
pub precise: Option<String>,
}
impl Start {
pub fn from_hashmap(mut attrs: HashMap<String, String>) -> Start {
Start {
time_offset: attrs.remove("TIME-OFFSET").unwrap_or_else(String::new),
precise: attrs.remove("PRECISE").or(Some("NO".to_string())),
}
}
pub fn write_to<T: Write>(&self, w: &mut T) -> std::io::Result<()> {
write!(w, "#EXT-X-START:TIME-OFFSET={}", self.time_offset)?;
write_some_attribute!(w, ",PRECISE", &self.precise)?;
write!(w, "\n")
}
}
#[derive(Debug, Default)]
pub struct ExtTag {
pub tag: String,
pub rest: String,
}