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
// 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 enclosure can be retrieved by using the methods under `Enclosure`.
use channels::Enclosure;
use mime::Mime;
use url::Url;
impl Enclosure {
/// Get the url that exists under `Enclosure`.
///
/// # Examples
///
/// ```
/// use feed::channels::EnclosureBuilder;
///
/// let url = "http://www.podtrac.com/pts/redirect.ogg/".to_owned()
/// + "traffic.libsyn.com/jnite/linuxactionshowep408.ogg";
/// let enclosure = EnclosureBuilder::new()
/// .url(url.as_ref())
/// .mime_type("audio/ogg")
/// .finalize();
/// assert_eq!(url.to_owned(), enclosure.url().into_string())
/// ```
pub fn url(&self) -> Url {
self.url.clone()
}
/// Get the length that exists under `Enclosure`.
///
/// # Examples
///
/// ```
/// use feed::channels::EnclosureBuilder;
///
/// let length: i64 = 70772893;
///
/// let url = "http://www.podtrac.com/pts/redirect.ogg/".to_owned()
/// + "traffic.libsyn.com/jnite/linuxactionshowep408.ogg";
///
/// let enclosure = EnclosureBuilder::new()
/// .url(url.as_str())
/// .length(length)
/// .mime_type("audio/ogg")
/// .finalize();
/// assert_eq!(length, enclosure.length())
/// ```
pub fn length(&self) -> i64 {
self.length
}
/// Get the enclosure type that exists under `Enclosure`.
///
/// # Examples
///
/// ```
/// use feed::channels::EnclosureBuilder;
///
/// let enclosure_type = "audio/ogg";
///
/// let url = "http://www.podtrac.com/pts/redirect.ogg/".to_owned()
/// + "traffic.libsyn.com/jnite/linuxactionshowep408.ogg";
///
/// let enclosure = EnclosureBuilder::new()
/// .url(url.as_str())
/// .mime_type(enclosure_type)
/// .finalize();
/// assert_eq!(enclosure_type.to_owned(), enclosure.mime_type().to_string())
/// ```
pub fn mime_type(&self) -> Mime {
self.mime_type.clone()
}
}