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
// Copyright (c) 2015-2016 Chris Palmer <pennstate5013@gmail.com>
// Use of this source code is governed by the LGPLv3 license that can be
// found in the LICENSE file.
//! The fields under category can be retrieved by using the methods under
//! `Category`.
use channels::Category;
use url::Url;
impl Category {
/// Get the category that exists under `Category`.
///
/// # Examples
///
/// ```
/// use feed::channels::CategoryBuilder;
///
/// let category = "podcast";
/// let category_obj = CategoryBuilder::new()
/// .name(category)
/// .finalize();
/// assert_eq!(category.to_owned(), category_obj.name());
/// ```
pub fn name(&self) -> String {
self.name.clone()
}
/// Get the optional domain that exists under `Category`.
///
/// # Examples
///
/// ```
/// use feed::channels::CategoryBuilder;
///
/// let domain_string = "http://jupiterbroadcasting.com/".to_owned();
/// let category = CategoryBuilder::new()
/// .domain(Some(domain_string.clone()))
/// .finalize();
/// let domain_option = category.domain();
/// assert!(domain_option.is_some());
/// let domain = domain_option.unwrap();
/// assert_eq!(domain_string.clone(), domain.into_string());
/// ```
///
/// ```
/// use feed::channels::CategoryBuilder;
///
/// let category = CategoryBuilder::new()
/// .domain(None)
/// .finalize();
/// let domain_option = category.domain();
/// assert!(domain_option.is_none());
/// ```
pub fn domain(&self) -> Option<Url> {
self.domain.clone()
}
}