1
1
//! Specify the compression algorithm.
2
2
3
- use crate :: content:: EncodingDirective ;
3
+ use crate :: content:: Encoding ;
4
4
use crate :: headers:: { HeaderName , HeaderValue , Headers , ToHeaderValues , CONTENT_ENCODING } ;
5
5
6
6
use std:: fmt:: { self , Debug , Write } ;
@@ -20,23 +20,23 @@ use std::slice;
20
20
/// # fn main() -> http_types::Result<()> {
21
21
/// #
22
22
/// use http_types::Response;
23
- /// use http_types::content::{ContentEncoding, EncodingDirective };
23
+ /// use http_types::content::{ContentEncoding, Encoding };
24
24
/// let mut entries = ContentEncoding::new();
25
- /// entries.push(EncodingDirective ::Gzip);
26
- /// entries.push(EncodingDirective ::Identity);
25
+ /// entries.push(Encoding ::Gzip);
26
+ /// entries.push(Encoding ::Identity);
27
27
///
28
28
/// let mut res = Response::new(200);
29
29
/// entries.apply(&mut res);
30
30
///
31
31
/// let entries = ContentEncoding::from_headers(res)?.unwrap();
32
32
/// let mut entries = entries.iter();
33
- /// assert_eq!(entries.next().unwrap(), &EncodingDirective ::Gzip);
34
- /// assert_eq!(entries.next().unwrap(), &EncodingDirective ::Identity);
33
+ /// assert_eq!(entries.next().unwrap(), &Encoding ::Gzip);
34
+ /// assert_eq!(entries.next().unwrap(), &Encoding ::Identity);
35
35
/// #
36
36
/// # Ok(()) }
37
37
/// ```
38
38
pub struct ContentEncoding {
39
- entries : Vec < EncodingDirective > ,
39
+ entries : Vec < Encoding > ,
40
40
}
41
41
42
42
impl ContentEncoding {
@@ -57,7 +57,7 @@ impl ContentEncoding {
57
57
for part in value. as_str ( ) . trim ( ) . split ( ',' ) {
58
58
// Try and parse a directive from a str. If the directive is
59
59
// unkown we skip it.
60
- if let Some ( entry) = EncodingDirective :: from_str ( part) {
60
+ if let Some ( entry) = Encoding :: from_str ( part) {
61
61
entries. push ( entry) ;
62
62
}
63
63
}
@@ -91,7 +91,7 @@ impl ContentEncoding {
91
91
unsafe { HeaderValue :: from_bytes_unchecked ( output. into ( ) ) }
92
92
}
93
93
/// Push a directive into the list of entries.
94
- pub fn push ( & mut self , directive : EncodingDirective ) {
94
+ pub fn push ( & mut self , directive : Encoding ) {
95
95
self . entries . push ( directive) ;
96
96
}
97
97
@@ -111,7 +111,7 @@ impl ContentEncoding {
111
111
}
112
112
113
113
impl IntoIterator for ContentEncoding {
114
- type Item = EncodingDirective ;
114
+ type Item = Encoding ;
115
115
type IntoIter = IntoIter ;
116
116
117
117
#[ inline]
@@ -123,7 +123,7 @@ impl IntoIterator for ContentEncoding {
123
123
}
124
124
125
125
impl < ' a > IntoIterator for & ' a ContentEncoding {
126
- type Item = & ' a EncodingDirective ;
126
+ type Item = & ' a Encoding ;
127
127
type IntoIter = Iter < ' a > ;
128
128
129
129
#[ inline]
@@ -133,7 +133,7 @@ impl<'a> IntoIterator for &'a ContentEncoding {
133
133
}
134
134
135
135
impl < ' a > IntoIterator for & ' a mut ContentEncoding {
136
- type Item = & ' a mut EncodingDirective ;
136
+ type Item = & ' a mut Encoding ;
137
137
type IntoIter = IterMut < ' a > ;
138
138
139
139
#[ inline]
@@ -145,11 +145,11 @@ impl<'a> IntoIterator for &'a mut ContentEncoding {
145
145
/// A borrowing iterator over entries in `CacheControl`.
146
146
#[ derive( Debug ) ]
147
147
pub struct IntoIter {
148
- inner : std:: vec:: IntoIter < EncodingDirective > ,
148
+ inner : std:: vec:: IntoIter < Encoding > ,
149
149
}
150
150
151
151
impl Iterator for IntoIter {
152
- type Item = EncodingDirective ;
152
+ type Item = Encoding ;
153
153
154
154
fn next ( & mut self ) -> Option < Self :: Item > {
155
155
self . inner . next ( )
@@ -164,11 +164,11 @@ impl Iterator for IntoIter {
164
164
/// A lending iterator over entries in `CacheControl`.
165
165
#[ derive( Debug ) ]
166
166
pub struct Iter < ' a > {
167
- inner : slice:: Iter < ' a , EncodingDirective > ,
167
+ inner : slice:: Iter < ' a , Encoding > ,
168
168
}
169
169
170
170
impl < ' a > Iterator for Iter < ' a > {
171
- type Item = & ' a EncodingDirective ;
171
+ type Item = & ' a Encoding ;
172
172
173
173
fn next ( & mut self ) -> Option < Self :: Item > {
174
174
self . inner . next ( )
@@ -183,11 +183,11 @@ impl<'a> Iterator for Iter<'a> {
183
183
/// A mutable iterator over entries in `CacheControl`.
184
184
#[ derive( Debug ) ]
185
185
pub struct IterMut < ' a > {
186
- inner : slice:: IterMut < ' a , EncodingDirective > ,
186
+ inner : slice:: IterMut < ' a , Encoding > ,
187
187
}
188
188
189
189
impl < ' a > Iterator for IterMut < ' a > {
190
- type Item = & ' a mut EncodingDirective ;
190
+ type Item = & ' a mut Encoding ;
191
191
192
192
fn next ( & mut self ) -> Option < Self :: Item > {
193
193
self . inner . next ( )
0 commit comments