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
// This file is part of rss.
//
// Copyright © 2015-2017 The rust-syndication Developers
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the MIT License and/or Apache 2.0 License.
use super::{parse_categories, parse_image, parse_owner};
use error::Error;
use extension::Extension;
use extension::itunes::ITunesCategory;
use extension::itunes::ITunesOwner;
use extension::remove_extension_value;
use quick_xml::{Element, Event, XmlWriter};
use quick_xml::error::Error as XmlError;
use std::collections::HashMap;
use toxml::{ToXml, XmlWriterExt};
/// An iTunes channel element extension.
#[derive(Debug, Default, Clone, PartialEq)]
pub struct ITunesChannelExtension {
/// The author of the podcast.
author: Option<String>,
/// Specifies if the podcast should be prevented from appearing in the iTunes Store. A value of
/// `Yes` indicates that the podcast should not show up in the iTunes Store. All other values
/// are ignored.
block: Option<String>,
/// The iTunes categories the podcast belongs to.
categories: Vec<ITunesCategory>,
/// The artwork for the podcast.
image: Option<String>,
/// Specifies whether the podcast contains explicit content. A value of `Yes`, `Explicit`, or
/// `True` indicates that the podcast contains explicit content. A value of `Clean`, `No`,
/// `False` inidicates that none of the episodes contain explicit content.
explicit: Option<String>,
/// Specifies whether the podcast is complete and no new episodes will be posted. A value of
/// `Yes` indicates that the podcast is complete.
complete: Option<String>,
/// The new URL where the podcast is located.
new_feed_url: Option<String>,
/// The contact information for the owner of the podcast.
owner: Option<ITunesOwner>,
/// A description of the podcast.
subtitle: Option<String>,
/// A summary of the podcast.
summary: Option<String>,
/// Keywords for the podcast. The string contains a comma separated list of keywords.
keywords: Option<String>,
}
impl ITunesChannelExtension {
/// Get the optional author that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let author = "author".to_string();
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .author(Some(author.clone()))
/// .finalize()
/// .unwrap();
///
/// let author_opt = channel.author();
/// assert!(author_opt.is_some());
///
/// assert_eq!(author.clone(), author_opt.unwrap());
/// ```
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .author(None)
/// .finalize()
/// .unwrap();
///
/// let author_opt = channel.author();
/// assert!(author_opt.is_none());
/// ```
pub fn author(&self) -> Option<&str> {
self.author.as_ref().map(|s| s.as_str())
}
/// Get the optional block that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let block = "block".to_string();
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .block(Some(block.clone()))
/// .finalize()
/// .unwrap();
///
/// let block_opt = channel.block();
/// assert!(block_opt.is_some());
///
/// assert_eq!(block.clone(), block_opt.unwrap());
/// ```
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .block(None)
/// .finalize()
/// .unwrap();
///
/// let block_opt = channel.block();
/// assert!(block_opt.is_none());
/// ```
pub fn block(&self) -> Option<&str> {
self.block.as_ref().map(|s| s.as_str())
}
/// Get the categories that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension, ITunesCategoryBuilder};
///
/// let subcategory = ITunesCategoryBuilder::new()
/// .text("text")
/// .finalize()
/// .unwrap();
///
/// let category = ITunesCategoryBuilder::new()
/// .text("text")
/// .subcategory(Some(Box::new(subcategory)))
/// .finalize()
/// .unwrap();
///
/// let categories_vec = vec![category];
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .categories(categories_vec)
/// .finalize()
/// .unwrap();
///
/// let categories = channel.categories();
/// assert!(!categories.is_empty());
/// ```
pub fn categories(&self) -> &[ITunesCategory] {
&self.categories
}
/// Get the optional image that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let image = "image".to_string();
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .image(Some(image.clone()))
/// .finalize()
/// .unwrap();
///
/// let image_opt = channel.image();
/// assert!(image_opt.is_some());
///
/// assert_eq!(image.clone(), image_opt.unwrap());
/// ```
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .image(None)
/// .finalize()
/// .unwrap();
///
/// let image_opt = channel.image();
/// assert!(image_opt.is_none());
/// ```
pub fn image(&self) -> Option<&str> {
self.image.as_ref().map(|s| s.as_str())
}
/// Get the optional explicit that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let explicit = "explicit".to_string();
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .explicit(Some(explicit.clone()))
/// .finalize()
/// .unwrap();
///
/// let explicit_opt = channel.explicit();
/// assert!(explicit_opt.is_some());
///
/// assert_eq!(explicit.clone(), explicit_opt.unwrap());
/// ```
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .explicit(None)
/// .finalize()
/// .unwrap();
///
/// let explicit_opt = channel.explicit();
/// assert!(explicit_opt.is_none());
/// ```
pub fn explicit(&self) -> Option<&str> {
self.explicit.as_ref().map(|s| s.as_str())
}
/// Get the optional complete that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let complete = "complete".to_string();
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .complete(Some(complete.clone()))
/// .finalize()
/// .unwrap();
///
/// let complete_opt = channel.complete();
/// assert!(complete_opt.is_some());
///
/// assert_eq!(complete.clone(), complete_opt.unwrap());
/// ```
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .complete(None)
/// .finalize()
/// .unwrap();
///
/// let complete_opt = channel.complete();
/// assert!(complete_opt.is_none());
/// ```
pub fn complete(&self) -> Option<&str> {
self.complete.as_ref().map(|s| s.as_str())
}
/// Get the optional new_feed_url that exists under
/// `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let new_feed_url = "new_feed_url".to_string();
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .new_feed_url(Some(new_feed_url.clone()))
/// .finalize()
/// .unwrap();
///
/// let new_feed_url_opt = channel.new_feed_url();
/// assert!(new_feed_url_opt.is_some());
///
/// assert_eq!(new_feed_url.clone(), new_feed_url_opt.unwrap());
/// ```
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .new_feed_url(None)
/// .finalize()
/// .unwrap();
///
/// let new_feed_url_opt = channel.new_feed_url();
/// assert!(new_feed_url_opt.is_none());
/// ```
pub fn new_feed_url(&self) -> Option<&str> {
self.new_feed_url.as_ref().map(|s| s.as_str())
}
/// Get the optional owner that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension, ITunesOwnerBuilder};
///
/// let owner = ITunesOwnerBuilder::new()
/// .email(Some("email@example.com".to_string()))
/// .name(Some("name".to_string()))
/// .finalize()
/// .unwrap();
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .owner(Some(owner))
/// .finalize()
/// .unwrap();
///
/// let owner_opt = channel.owner();
/// assert!(owner_opt.is_some());
/// ```
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .owner(None)
/// .finalize()
/// .unwrap();
///
/// let owner_opt = channel.owner();
/// assert!(owner_opt.is_none());
/// ```
pub fn owner(&self) -> Option<&ITunesOwner> {
self.owner.as_ref()
}
/// Get the optional subtitle that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let subtitle = "subtitle".to_string();
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .subtitle(Some(subtitle.clone()))
/// .finalize()
/// .unwrap();
///
/// let subtitle_opt = channel.subtitle();
/// assert!(subtitle_opt.is_some());
///
/// assert_eq!(subtitle.clone(), subtitle_opt.unwrap());
/// ```
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .subtitle(None)
/// .finalize()
/// .unwrap();
///
/// let subtitle_opt = channel.subtitle();
/// assert!(subtitle_opt.is_none());
/// ```
pub fn subtitle(&self) -> Option<&str> {
self.subtitle.as_ref().map(|s| s.as_str())
}
/// Get the optional summary that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let summary = "summary".to_string();
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .summary(Some(summary.clone()))
/// .finalize()
/// .unwrap();
///
/// let summary_opt = channel.summary();
/// assert!(summary_opt.is_some());
///
/// assert_eq!(summary.clone(), summary_opt.unwrap());
/// ```
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .summary(None)
/// .finalize()
/// .unwrap();
///
/// let summary_opt = channel.summary();
/// assert!(summary_opt.is_none());
/// ```
pub fn summary(&self) -> Option<&str> {
self.summary.as_ref().map(|s| s.as_str())
}
/// Get the optional keywords that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let keywords = "keywords".to_string();
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .keywords(Some(keywords.clone()))
/// .finalize()
/// .unwrap();
///
/// let keywords_opt = channel.keywords();
/// assert!(keywords_opt.is_some());
///
/// assert_eq!(keywords.clone(), keywords_opt.unwrap());
/// ```
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesChannelExtension};
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .keywords(None)
/// .finalize()
/// .unwrap();
///
/// let keywords_opt = channel.keywords();
/// assert!(keywords_opt.is_none());
/// ```
pub fn keywords(&self) -> Option<&str> {
self.keywords.as_ref().map(|s| s.as_str())
}
}
impl ITunesChannelExtension {
/// Creates an ITunesChannelExtension using the specified hashmap.
pub fn from_map(mut map: HashMap<String, Vec<Extension>>) -> Result<Self, Error> {
let mut ext = ITunesChannelExtension::default();
ext.author = remove_extension_value(&mut map, "author");
ext.block = remove_extension_value(&mut map, "block");
ext.categories = parse_categories(&mut map)?;
ext.image = parse_image(&mut map);
ext.explicit = remove_extension_value(&mut map, "explicit");
ext.complete = remove_extension_value(&mut map, "complete");
ext.new_feed_url = remove_extension_value(&mut map, "new-feed-url");
ext.owner = parse_owner(&mut map)?;
ext.subtitle = remove_extension_value(&mut map, "subtitle");
ext.summary = remove_extension_value(&mut map, "summary");
ext.keywords = remove_extension_value(&mut map, "keywords");
Ok(ext)
}
}
impl ToXml for ITunesChannelExtension {
fn to_xml<W: ::std::io::Write>(&self, writer: &mut XmlWriter<W>) -> Result<(), XmlError> {
if let Some(author) = self.author.as_ref() {
writer.write_text_element(b"itunes:author", author)?;
}
if let Some(block) = self.block.as_ref() {
writer.write_text_element(b"itunes:block", block)?;
}
writer.write_objects(&self.categories)?;
if let Some(image) = self.image.as_ref() {
let element = Element::new(b"itunes:image");
writer
.write(Event::Start({
let mut element = element.clone();
element.extend_attributes(::std::iter::once((b"href",
image)));
element
}))?;
writer.write(Event::End(element))?;
}
if let Some(explicit) = self.explicit.as_ref() {
writer.write_text_element(b"itunes:explicit", explicit)?;
}
if let Some(complete) = self.complete.as_ref() {
writer.write_text_element(b"itunes:complete", complete)?;
}
if let Some(new_feed_url) = self.new_feed_url.as_ref() {
writer
.write_text_element(b"itunes:new-feed-url", new_feed_url)?;
}
if let Some(owner) = self.owner.as_ref() {
writer.write_object(owner)?;
}
if let Some(subtitle) = self.subtitle.as_ref() {
writer.write_text_element(b"itunes:subtitle", subtitle)?;
}
if let Some(summary) = self.summary.as_ref() {
writer.write_text_element(b"itunes:summary", summary)?;
}
if let Some(keywords) = self.keywords.as_ref() {
writer.write_text_element(b"itunes:keywords", keywords)?;
}
Ok(())
}
}
/// This `ITunesChannelExtensionBuilder` struct creates the
/// `ITunesChannelExtension`.
#[derive(Debug, Clone, Default)]
pub struct ITunesChannelExtensionBuilder {
author: Option<String>,
block: Option<String>,
categories: Vec<ITunesCategory>,
image: Option<String>,
explicit: Option<String>,
complete: Option<String>,
new_feed_url: Option<String>,
owner: Option<ITunesOwner>,
subtitle: Option<String>,
summary: Option<String>,
keywords: Option<String>,
}
impl ITunesChannelExtensionBuilder {
/// Construct a new `ITunesChannelExtension` and return default values.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::ITunesChannelExtensionBuilder;
///
/// let channel_builder = ITunesChannelExtensionBuilder::new();
/// ```
pub fn new() -> ITunesChannelExtensionBuilder {
ITunesChannelExtensionBuilder::default()
}
/// Set the optional author that exists under `ITunesChannelExtension`.
///
/// ```
/// use rss::extension::itunes::ITunesChannelExtensionBuilder;
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.author(Some("author".to_string()));
/// ```
pub fn author(mut self, author: Option<String>) -> ITunesChannelExtensionBuilder {
self.author = author;
self
}
/// Set the optional block that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::ITunesChannelExtensionBuilder;
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.block(Some("block".to_string()));
/// ```
pub fn block(mut self, block: Option<String>) -> ITunesChannelExtensionBuilder {
self.block = block;
self
}
/// Set the categories that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesCategoryBuilder,
/// ITunesChannelExtensionBuilder};
///
/// let subcategory = ITunesCategoryBuilder::new()
/// .text("text")
/// .finalize()
/// .unwrap();
///
/// let category = ITunesCategoryBuilder::new()
/// .text("text")
/// .subcategory(Some(Box::new(subcategory)))
/// .finalize()
/// .unwrap();
///
/// let categories = vec![category];
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.categories(categories);
/// ```
pub fn categories(mut self, categories: Vec<ITunesCategory>) -> ITunesChannelExtensionBuilder {
self.categories = categories;
self
}
/// Set the optional image that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::ITunesChannelExtensionBuilder;
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.image(Some("image".to_string()));
/// ```
pub fn image(mut self, image: Option<String>) -> ITunesChannelExtensionBuilder {
self.image = image;
self
}
/// Set the optional explicit that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::ITunesChannelExtensionBuilder;
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.explicit(Some("explicit".to_string()));
/// ```
pub fn explicit(mut self, explicit: Option<String>) -> ITunesChannelExtensionBuilder {
self.explicit = explicit;
self
}
/// Set the optional complete that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::ITunesChannelExtensionBuilder;
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.complete(Some("complete".to_string()));
/// ```
pub fn complete(mut self, complete: Option<String>) -> ITunesChannelExtensionBuilder {
self.complete = complete;
self
}
/// Set the optional new_feed_url that exists under
/// `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::ITunesChannelExtensionBuilder;
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.new_feed_url(Some("new_feed_url".to_string()));
/// ```
pub fn new_feed_url(mut self, new_feed_url: Option<String>) -> ITunesChannelExtensionBuilder {
self.new_feed_url = new_feed_url;
self
}
/// Set the optional owner that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesChannelExtensionBuilder,
/// ITunesOwnerBuilder};
///
/// let owner = ITunesOwnerBuilder::new()
/// .email(Some("email@example.com".to_string()))
/// .name(Some("name".to_string()))
/// .finalize()
/// .unwrap();
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.owner(Some(owner));
/// ```
pub fn owner(mut self, owner: Option<ITunesOwner>) -> ITunesChannelExtensionBuilder {
self.owner = owner;
self
}
/// Set the optional subtitle that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::ITunesChannelExtensionBuilder;
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.subtitle(Some("subtitle".to_string()));
/// ```
pub fn subtitle(mut self, subtitle: Option<String>) -> ITunesChannelExtensionBuilder {
self.subtitle = subtitle;
self
}
/// Set the optional summary that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::ITunesChannelExtensionBuilder;
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.summary(Some("summary".to_string()));
/// ```
pub fn summary(mut self, summary: Option<String>) -> ITunesChannelExtensionBuilder {
self.summary = summary;
self
}
/// Set the optional keywords that exists under `ITunesChannelExtension`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::ITunesChannelExtensionBuilder;
///
/// let mut channel_builder = ITunesChannelExtensionBuilder::new();
/// channel_builder.keywords(Some("keywords".to_string()));
/// ```
pub fn keywords(mut self, keywords: Option<String>) -> ITunesChannelExtensionBuilder {
self.keywords = keywords;
self
}
/// Construct the `ITunesChannelExtension` from the
/// `ITunesChannelExtensionBuilder`.
///
/// # Examples
///
/// ```
/// use rss::extension::itunes::{ITunesCategoryBuilder,
/// ITunesChannelExtensionBuilder, ITunesOwnerBuilder};
///
/// let owner = ITunesOwnerBuilder::new()
/// .email(Some("email@example.com".to_string()))
/// .name(Some("name".to_string()))
/// .finalize()
/// .unwrap();
///
/// let subcategory = ITunesCategoryBuilder::new()
/// .text("text")
/// .finalize()
/// .unwrap();
///
/// let category = ITunesCategoryBuilder::new()
/// .text("text")
/// .subcategory(Some(Box::new(subcategory)))
/// .finalize()
/// .unwrap();
///
/// let categories = vec![category];
///
/// let channel = ITunesChannelExtensionBuilder::new()
/// .author(Some("author".to_string()))
/// .block(Some("block".to_string()))
/// .image(Some("image".to_string()))
/// .explicit(Some("explicit".to_string()))
/// .subtitle(Some("subtitle".to_string()))
/// .summary(Some("summary".to_string()))
/// .keywords(Some("keywords".to_string()))
/// .new_feed_url(Some("new_feed_url".to_string()))
/// .complete(Some("complete".to_string()))
/// .owner(Some(owner))
/// .categories(categories)
/// .finalize()
/// .unwrap();
/// ```
pub fn finalize(self) -> Result<ITunesChannelExtension, Error> {
Ok(ITunesChannelExtension {
author: self.author,
block: self.block,
categories: self.categories,
image: self.image,
explicit: self.explicit,
complete: self.complete,
new_feed_url: self.new_feed_url,
owner: self.owner,
subtitle: self.subtitle,
summary: self.summary,
keywords: self.keywords,
})
}
}